Skip to content

Commit

Permalink
Design Assembly Cleanup
Browse files Browse the repository at this point in the history
This change cleans up the .Design assemblies. Changes include:
- Tweak build configurations so the project now builds successfully for
all configurations.
- Remove unused WinRT references from the design assemblies.
- Removes some dead code.
- Use nameof() instead of string literals when setting extensible
attributes.
  • Loading branch information
mtaron committed Feb 26, 2016
1 parent a9b72d7 commit e16d9f5
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 166 deletions.
16 changes: 4 additions & 12 deletions src/BehaviorsSDKManaged/BehaviorsSDKManaged.sln
Original file line number Diff line number Diff line change
Expand Up @@ -66,33 +66,25 @@ Global
{76BF4E75-B1E7-4BFA-AE67-BAF6800DAC78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{76BF4E75-B1E7-4BFA-AE67-BAF6800DAC78}.Debug|Any CPU.Build.0 = Debug|Any CPU
{76BF4E75-B1E7-4BFA-AE67-BAF6800DAC78}.Debug|ARM.ActiveCfg = Debug|Any CPU
{76BF4E75-B1E7-4BFA-AE67-BAF6800DAC78}.Debug|ARM.Build.0 = Debug|Any CPU
{76BF4E75-B1E7-4BFA-AE67-BAF6800DAC78}.Debug|x64.ActiveCfg = Debug|Any CPU
{76BF4E75-B1E7-4BFA-AE67-BAF6800DAC78}.Debug|x64.Build.0 = Debug|Any CPU
{76BF4E75-B1E7-4BFA-AE67-BAF6800DAC78}.Debug|x86.ActiveCfg = Debug|Any CPU
{76BF4E75-B1E7-4BFA-AE67-BAF6800DAC78}.Debug|x86.Build.0 = Debug|Any CPU
{76BF4E75-B1E7-4BFA-AE67-BAF6800DAC78}.Debug|x86.ActiveCfg = Debug|x86
{76BF4E75-B1E7-4BFA-AE67-BAF6800DAC78}.Debug|x86.Build.0 = Debug|x86
{76BF4E75-B1E7-4BFA-AE67-BAF6800DAC78}.Release|Any CPU.ActiveCfg = Release|Any CPU
{76BF4E75-B1E7-4BFA-AE67-BAF6800DAC78}.Release|Any CPU.Build.0 = Release|Any CPU
{76BF4E75-B1E7-4BFA-AE67-BAF6800DAC78}.Release|ARM.ActiveCfg = Release|Any CPU
{76BF4E75-B1E7-4BFA-AE67-BAF6800DAC78}.Release|ARM.Build.0 = Release|Any CPU
{76BF4E75-B1E7-4BFA-AE67-BAF6800DAC78}.Release|x64.ActiveCfg = Release|Any CPU
{76BF4E75-B1E7-4BFA-AE67-BAF6800DAC78}.Release|x64.Build.0 = Release|Any CPU
{76BF4E75-B1E7-4BFA-AE67-BAF6800DAC78}.Release|x86.ActiveCfg = Release|Any CPU
{76BF4E75-B1E7-4BFA-AE67-BAF6800DAC78}.Release|x86.Build.0 = Release|Any CPU
{A3161818-5AA8-4A7C-A6CD-B19EDA5F3AE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A3161818-5AA8-4A7C-A6CD-B19EDA5F3AE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A3161818-5AA8-4A7C-A6CD-B19EDA5F3AE1}.Debug|ARM.ActiveCfg = Debug|Any CPU
{A3161818-5AA8-4A7C-A6CD-B19EDA5F3AE1}.Debug|ARM.Build.0 = Debug|Any CPU
{A3161818-5AA8-4A7C-A6CD-B19EDA5F3AE1}.Debug|x64.ActiveCfg = Debug|Any CPU
{A3161818-5AA8-4A7C-A6CD-B19EDA5F3AE1}.Debug|x64.Build.0 = Debug|Any CPU
{A3161818-5AA8-4A7C-A6CD-B19EDA5F3AE1}.Debug|x86.ActiveCfg = Debug|Any CPU
{A3161818-5AA8-4A7C-A6CD-B19EDA5F3AE1}.Debug|x86.Build.0 = Debug|Any CPU
{A3161818-5AA8-4A7C-A6CD-B19EDA5F3AE1}.Debug|x86.ActiveCfg = Debug|x86
{A3161818-5AA8-4A7C-A6CD-B19EDA5F3AE1}.Debug|x86.Build.0 = Debug|x86
{A3161818-5AA8-4A7C-A6CD-B19EDA5F3AE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A3161818-5AA8-4A7C-A6CD-B19EDA5F3AE1}.Release|Any CPU.Build.0 = Release|Any CPU
{A3161818-5AA8-4A7C-A6CD-B19EDA5F3AE1}.Release|ARM.ActiveCfg = Release|Any CPU
{A3161818-5AA8-4A7C-A6CD-B19EDA5F3AE1}.Release|ARM.Build.0 = Release|Any CPU
{A3161818-5AA8-4A7C-A6CD-B19EDA5F3AE1}.Release|x64.ActiveCfg = Release|Any CPU
{A3161818-5AA8-4A7C-A6CD-B19EDA5F3AE1}.Release|x64.Build.0 = Release|Any CPU
{A3161818-5AA8-4A7C-A6CD-B19EDA5F3AE1}.Release|x86.ActiveCfg = Release|Any CPU
{A3161818-5AA8-4A7C-A6CD-B19EDA5F3AE1}.Release|x86.Build.0 = Release|Any CPU
{9A26166B-1E98-4723-9B42-FB64BDC231E6}.Debug|Any CPU.ActiveCfg = Debug|x86
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

extern alias WindowsRuntime;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using Microsoft.Windows.Design.Metadata;
using Microsoft.Windows.Design.PropertyEditing;
using Microsoft.Windows.Design.PropertyEditing.Editors;
Expand All @@ -31,29 +28,26 @@ public AttributeTable AttributeTable

#region IncrementalUpdateBehavior
AddAttributes<IncrementalUpdateBehavior>(
new DescriptionAttribute(Resources.Description_IncrementalUpdateBehavior)
);
new DescriptionAttribute(Resources.Description_IncrementalUpdateBehavior));

AddAttributes<IncrementalUpdateBehavior>(
"Phase",
nameof(IncrementalUpdateBehavior.Phase),
new DescriptionAttribute(Resources.Description_IncrementalUpdateBehavior_Phase),
new CategoryAttribute(Resources.Category_Common_Properties));
#endregion

#region EventTriggerBehavior
AddAttributes<EventTriggerBehavior>(
new DescriptionAttribute(Resources.Description_EventTriggerBehavior)
);
new DescriptionAttribute(Resources.Description_EventTriggerBehavior));

AddAttributes<EventTriggerBehavior>(
"EventName",
nameof(EventTriggerBehavior.EventName),
new DescriptionAttribute(Resources.Description_EventTriggerBehavior_EventName),
CreateEditorAttribute<EventPickerPropertyValueEditor>(),
new CategoryAttribute(Resources.Category_Common_Properties)
);
new CategoryAttribute(Resources.Category_Common_Properties));

AddAttributes<EventTriggerBehavior>(
"SourceObject",
nameof(EventTriggerBehavior.SourceObject),
new DescriptionAttribute(Resources.Description_EventTriggerBehavior_SourceObject),
CreateEditorAttribute<ElementBindingPickerPropertyValueEditor>(),
new CategoryAttribute(Resources.Category_Common_Properties));
Expand All @@ -65,22 +59,21 @@ public AttributeTable AttributeTable

#region DataTriggerBehavior
AddAttributes<DataTriggerBehavior>(
new DefaultBindingPropertyAttribute("Binding")
);
new DefaultBindingPropertyAttribute(nameof(DataTriggerBehavior.Binding)));

AddAttributes<DataTriggerBehavior>(
"Binding",
nameof(DataTriggerBehavior.Binding),
new DescriptionAttribute(Resources.Description_DataTriggerBehavior_Binding),
CreateEditorAttribute<PropertyBindingPickerPropertyValueEditor>(),
new CategoryAttribute(Resources.Category_Common_Properties));

AddAttributes<DataTriggerBehavior>(
"ComparisonCondition",
nameof(DataTriggerBehavior.ComparisonCondition),
new DescriptionAttribute(Resources.Description_DataTriggerBehavior_ComparisonCondition),
new CategoryAttribute(Resources.Category_Common_Properties));

AddAttributes<DataTriggerBehavior>(
"Value",
nameof(DataTriggerBehavior.Value),
new DescriptionAttribute(Resources.Description_DataTriggerBehavior_Value),
new CategoryAttribute(Resources.Category_Common_Properties),
new TypeConverterAttribute(typeof(StringConverter)));
Expand All @@ -92,23 +85,22 @@ public AttributeTable AttributeTable

#region ChangePropertyAction
AddAttributes<ChangePropertyAction>(
new DescriptionAttribute(Resources.Description_ChangePropertyAction)
);
new DescriptionAttribute(Resources.Description_ChangePropertyAction));

AddAttributes<ChangePropertyAction>(
"PropertyName",
nameof(ChangePropertyAction.PropertyName),
CreateEditorAttribute<PropertyPickerPropertyValueEditor>(),
new CategoryAttribute(Resources.Category_Common_Properties),
new DescriptionAttribute(Resources.Description_ChangePropertyAction_PropertyName));

AddAttributes<ChangePropertyAction>(
"TargetObject",
nameof(ChangePropertyAction.TargetObject),
new DescriptionAttribute(Resources.Description_ChangePropertyAction_TargetObject),
CreateEditorAttribute<ElementBindingPickerPropertyValueEditor>(),
new CategoryAttribute(Resources.Category_Common_Properties));

AddAttributes<ChangePropertyAction>(
"Value",
nameof(ChangePropertyAction.Value),
new DescriptionAttribute(Resources.Description_ChangePropertyAction_Value),
new CategoryAttribute(Resources.Category_Common_Properties),
new BrowsableAttribute(false));
Expand All @@ -118,36 +110,36 @@ public AttributeTable AttributeTable
#region InvokeCommandAction
AddAttributes<InvokeCommandAction>(
new DescriptionAttribute(Resources.Description_InvokeCommandAction),
new DefaultBindingPropertyAttribute("Command"));
new DefaultBindingPropertyAttribute(nameof(InvokeCommandAction.Command)));

AddAttributes<InvokeCommandAction>(
"Command",
nameof(InvokeCommandAction.Command),
new CategoryAttribute(Resources.Category_Common_Properties),
CreateEditorAttribute<PropertyBindingPickerPropertyValueEditor>(),
new DescriptionAttribute(Resources.Description_InvokeCommandAction_Command));

AddAttributes<InvokeCommandAction>(
"CommandParameter",
nameof(InvokeCommandAction.CommandParameter),
new TypeConverterAttribute(typeof(StringConverter)),
new CategoryAttribute(Resources.Category_Common_Properties),
new DescriptionAttribute(Resources.Description_InvokeCommandAction_CommandParameter),
new EditorBrowsableAttribute(EditorBrowsableState.Advanced));

AddAttributes<InvokeCommandAction>(
"InputConverter",
nameof(InvokeCommandAction.InputConverter),
new CategoryAttribute(Resources.Category_Common_Properties),
new DescriptionAttribute(Resources.Description_InvokeCommandAction_InputConverter),
new EditorBrowsableAttribute(EditorBrowsableState.Advanced));

AddAttributes<InvokeCommandAction>(
"InputConverterParameter",
nameof(InvokeCommandAction.InputConverterParameter),
new TypeConverterAttribute(typeof(StringConverter)),
new CategoryAttribute(Resources.Category_Common_Properties),
new DescriptionAttribute(Resources.Description_InvokeCommandAction_InputConverterParameter),
new EditorBrowsableAttribute(EditorBrowsableState.Advanced));

AddAttributes<InvokeCommandAction>(
"InputConverterLanguage",
nameof(InvokeCommandAction.InputConverterLanguage),
new CategoryAttribute(Resources.Category_Common_Properties),
new DescriptionAttribute(Resources.Description_InvokeCommandAction_InputConverterLanguage),
new TypeConverterAttribute(typeof(CultureInfoNamesConverter)),
Expand All @@ -156,16 +148,15 @@ public AttributeTable AttributeTable

#region ControlStoryboardAction
AddAttributes<ControlStoryboardAction>(
new DescriptionAttribute(Resources.Description_ControlStoryboardAction)
);
new DescriptionAttribute(Resources.Description_ControlStoryboardAction));

AddAttributes<ControlStoryboardAction>(
"ControlStoryboardOption",
nameof(ControlStoryboardAction.ControlStoryboardOption),
new DescriptionAttribute(Resources.Description_ControlStoryboardAction_ControlStoryboardOption),
new CategoryAttribute(Resources.Category_Common_Properties));

AddAttributes<ControlStoryboardAction>(
"Storyboard",
nameof(ControlStoryboardAction.Storyboard),
new DescriptionAttribute(Resources.Description_ControlStoryboardAction_Storyboard),
new CategoryAttribute(Resources.Category_Common_Properties),
CreateEditorAttribute<StoryboardPickerPropertyValueEditor>(),
Expand All @@ -174,59 +165,56 @@ public AttributeTable AttributeTable

#region GotoStateAction
AddAttributes<GoToStateAction>(
new DescriptionAttribute(Resources.Description_GoToStateAction)
);
new DescriptionAttribute(Resources.Description_GoToStateAction));

AddAttributes<GoToStateAction>(
"StateName",
nameof(GoToStateAction.StateName),
CreateEditorAttribute<StatePickerPropertyValueEditor>(),
new DescriptionAttribute(Resources.Description_GoToStateAction_StateName),
new CategoryAttribute(Resources.Category_Common_Properties));

AddAttributes<GoToStateAction>(
"UseTransitions",
nameof(GoToStateAction.UseTransitions),
new DescriptionAttribute(Resources.Description_GoToStateAction_UseTransitions),
new CategoryAttribute(Resources.Category_Common_Properties));

AddAttributes<GoToStateAction>(
"TargetObject",
nameof(GoToStateAction.TargetObject),
new CategoryAttribute(Resources.Category_Common_Properties),
new DescriptionAttribute(Resources.Description_GoToStateAction_TargetObject),
CreateEditorAttribute<ElementBindingPickerPropertyValueEditor>());
#endregion

#region NavigateToPageAction
AddAttributes<NavigateToPageAction>(
new DescriptionAttribute(Resources.Description_NavigateToPageAction)
);
new DescriptionAttribute(Resources.Description_NavigateToPageAction));

AddAttributes<NavigateToPageAction>(
"TargetPage",
nameof(NavigateToPageAction.TargetPage),
CreateEditorAttribute<PagePickerPropertyValueEditor>(),
new DescriptionAttribute(Resources.Description_NavigateToPageAction_TargetPage),
new CategoryAttribute(Resources.Category_Common_Properties));

AddAttributes<NavigateToPageAction>(
"Parameter",
nameof(NavigateToPageAction.Parameter),
new DescriptionAttribute(Resources.Description_NavigateToPageAction_Parameter),
new CategoryAttribute(Resources.Category_Common_Properties),
new TypeConverterAttribute(typeof(StringConverter)));
#endregion

#region PlaySoundAction
AddAttributes<PlaySoundAction>(
new DescriptionAttribute(Resources.Description_PlaySoundAction)
);
new DescriptionAttribute(Resources.Description_PlaySoundAction));

AddAttributes<PlaySoundAction>(
"Source",
nameof(PlaySoundAction.Source),
CreateEditorAttribute<UriPropertyValueEditor>(),
new DescriptionAttribute(Resources.Description_PlaySoundAction_Source),
new CategoryAttribute(Resources.Category_Common_Properties));

AddAttributes<PlaySoundAction>(
"Volume",
new NumberRangesAttribute(0, 0, 1, 1, false),
nameof(PlaySoundAction.Volume),
new NumberRangesAttribute(0, 0, 1, 1, canBeAuto: false),
new NumberIncrementsAttribute(0.001, 0.01, 0.1),
new DescriptionAttribute(Resources.Description_PlaySoundAction_Volume),
new CategoryAttribute(Resources.Category_Common_Properties));
Expand All @@ -237,17 +225,17 @@ public AttributeTable AttributeTable

AddAttributes<CallMethodAction>(
new DescriptionAttribute(Resources.Description_CallMethodAction),
new DefaultBindingPropertyAttribute("TargetObject"));
new DefaultBindingPropertyAttribute(nameof(CallMethodAction.TargetObject)));

AddAttributes<CallMethodAction>(
"TargetObject",
nameof(CallMethodAction.TargetObject),
new PropertyOrderAttribute(order = PropertyOrder.CreateAfter(order)),
new DescriptionAttribute(Resources.Description_CallMethodAction_TargetObject),
CreateEditorAttribute<ElementBindingPickerPropertyValueEditor>(),
new CategoryAttribute(Resources.Category_Common_Properties));

AddAttributes<CallMethodAction>(
"MethodName",
nameof(CallMethodAction.MethodName),
new PropertyOrderAttribute(order = PropertyOrder.CreateAfter(order)),
new DescriptionAttribute(Resources.Description_CallMethodAction_MethodName),
new CategoryAttribute(Resources.Category_Common_Properties));
Expand Down Expand Up @@ -288,27 +276,4 @@ private static EditorAttribute CreateEditorAttribute<T>() where T : PropertyValu
}

}

public static class RuntimeMethodExtensions
{
public static MethodInfo GetRuntimeMethodExt(this Type type, string name, params Type[] types)
{
List<string> typeNames = new List<string>();
foreach (Type localType in types)
{
typeNames.Add(localType.Name);
}
// Find potential methods with the correct name and the right number of parameters
// and parameter names
var potentials = (from ele in type.GetRuntimeMethods()
where ele.Name.Equals(name)
let param = ele.GetParameters()
where param.Length == types.Length
&& param.Select(p => p.ParameterType.Name).SequenceEqual(typeNames)
select ele);

// Maybe check if we have more than 1? Or not?
return potentials.FirstOrDefault();
}
}
}
Loading

1 comment on commit e16d9f5

@drewgillies
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking through the errors on the CI build output, there are some issues relating to the interactions design assembly around the resolution of value editor types. Looks like the removal of sn info in the assembly reference broke this.

Please sign in to comment.