diff --git a/sample/Atc.Wpf.Sample/Atc.Wpf.Sample.csproj b/sample/Atc.Wpf.Sample/Atc.Wpf.Sample.csproj index 790104ad..9b5841e4 100644 --- a/sample/Atc.Wpf.Sample/Atc.Wpf.Sample.csproj +++ b/sample/Atc.Wpf.Sample/Atc.Wpf.Sample.csproj @@ -65,29 +65,4 @@ - - - - - - - True - True - Word.resx - - - - - - PublicResXFileCodeGenerator - - - PublicResXFileCodeGenerator - - - PublicResXFileCodeGenerator - Word.Designer.cs - - - diff --git a/sample/Atc.Wpf.Sample/SamplesWpfControls/Monitoring/ApplicationMonitorView.xaml b/sample/Atc.Wpf.Sample/SamplesWpfControls/Monitoring/ApplicationMonitorView.xaml index 2f00fb0d..c0510e77 100644 --- a/sample/Atc.Wpf.Sample/SamplesWpfControls/Monitoring/ApplicationMonitorView.xaml +++ b/sample/Atc.Wpf.Sample/SamplesWpfControls/Monitoring/ApplicationMonitorView.xaml @@ -5,7 +5,6 @@ xmlns:atc="https://github.com/atc-net/atc-wpf/tree/main/schemas" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:monitoring="clr-namespace:Atc.Wpf.Controls.Monitoring;assembly=Atc.Wpf.Controls" xmlns:sample="clr-namespace:Atc.Wpf.Sample.SamplesWpfControls.Monitoring" d:DataContext="{d:DesignInstance Type=sample:ApplicationMonitorView}" d:DesignHeight="600" @@ -74,7 +73,7 @@ - True Validations.resx + + Word.resx + True + True + @@ -99,6 +104,16 @@ PublicResXFileCodeGenerator Validations.Designer.cs + + PublicResXFileCodeGenerator + + + PublicResXFileCodeGenerator + + + Word.Designer.cs + PublicResXFileCodeGenerator + diff --git a/sample/Atc.Wpf.Sample/Resource/Word.Designer.cs b/src/Atc.Wpf.Controls/Resources/Word.Designer.cs similarity index 99% rename from sample/Atc.Wpf.Sample/Resource/Word.Designer.cs rename to src/Atc.Wpf.Controls/Resources/Word.Designer.cs index 3a564ea2..4348ed99 100644 --- a/sample/Atc.Wpf.Sample/Resource/Word.Designer.cs +++ b/src/Atc.Wpf.Controls/Resources/Word.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Atc.Wpf.Sample.Resource { +namespace Atc.Wpf.Controls.Resources { using System; @@ -39,7 +39,7 @@ internal Word() { public static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Atc.Wpf.Sample.Resource.Word", typeof(Word).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Atc.Wpf.Controls.Resources.Word", typeof(Word).Assembly); resourceMan = temp; } return resourceMan; diff --git a/sample/Atc.Wpf.Sample/Resource/Word.da-DK.resx b/src/Atc.Wpf.Controls/Resources/Word.da-DK.resx similarity index 100% rename from sample/Atc.Wpf.Sample/Resource/Word.da-DK.resx rename to src/Atc.Wpf.Controls/Resources/Word.da-DK.resx diff --git a/sample/Atc.Wpf.Sample/Resource/Word.de-DE.resx b/src/Atc.Wpf.Controls/Resources/Word.de-DE.resx similarity index 100% rename from sample/Atc.Wpf.Sample/Resource/Word.de-DE.resx rename to src/Atc.Wpf.Controls/Resources/Word.de-DE.resx diff --git a/sample/Atc.Wpf.Sample/Resource/Word.resx b/src/Atc.Wpf.Controls/Resources/Word.resx similarity index 100% rename from sample/Atc.Wpf.Sample/Resource/Word.resx rename to src/Atc.Wpf.Controls/Resources/Word.resx diff --git a/src/Atc.Wpf.SourceGenerators/Extensions/CodeAnalysis/AttributeDataExtensions.cs b/src/Atc.Wpf.SourceGenerators/Extensions/CodeAnalysis/AttributeDataExtensions.cs index a9c0db19..dabd7717 100644 --- a/src/Atc.Wpf.SourceGenerators/Extensions/CodeAnalysis/AttributeDataExtensions.cs +++ b/src/Atc.Wpf.SourceGenerators/Extensions/CodeAnalysis/AttributeDataExtensions.cs @@ -2,18 +2,17 @@ namespace Atc.Wpf.SourceGenerators.Extensions.CodeAnalysis; internal static class AttributeDataExtensions { + [SuppressMessage("Design", "MA0051:Method is too long", Justification = "OK.")] public static Dictionary ExtractConstructorArgumentValues( this AttributeData attributeData) { - var result = new Dictionary(StringComparer.Ordinal); - if (attributeData.ConstructorArguments.Length == 0 && attributeData.NamedArguments.Length == 0) { // Syntax check if (attributeData.ApplicationSyntaxReference is not null) { - result = attributeData + return attributeData .ApplicationSyntaxReference .GetSyntax() .ToFullString() @@ -23,41 +22,10 @@ internal static class AttributeDataExtensions else { // Runtime check - var arrayIndex = 0; - foreach (var arg in attributeData.ConstructorArguments) - { - if (arg.Kind == TypedConstantKind.Array) - { - foreach (var typedConstant in arg.Values) - { - if (typedConstant.Value is null) - { - continue; - } - - arrayIndex++; - result.Add( - arrayIndex.ToString(CultureInfo.InvariantCulture), - typedConstant.Value.ToString()); - } - } - else if (arg.Value is not null) - { - result.Add( - NameConstants.Name, - arg.Value.ToString()); - } - } - - foreach (var arg in attributeData.NamedArguments) - { - result.Add( - arg.Key, - arg.Value.Value?.ToString()); - } + return RunTimeExtractConstructorArgumentValues(attributeData); } - return result; + return new Dictionary(StringComparer.Ordinal); } public static string ExtractClassFirstArgumentType( @@ -80,4 +48,63 @@ public static string ExtractClassFirstArgumentType( return type; } + + private static Dictionary RunTimeExtractConstructorArgumentValues( + AttributeData attributeData) + { + var result = new Dictionary(StringComparer.Ordinal); + + var arrayIndex = 0; + foreach (var arg in attributeData.ConstructorArguments) + { + if (arg.Kind == TypedConstantKind.Array) + { + foreach (var typedConstant in arg.Values) + { + if (typedConstant.Value is null) + { + continue; + } + + arrayIndex++; + result.Add( + arrayIndex.ToString(CultureInfo.InvariantCulture), + typedConstant.Value.ToString()); + } + } + else if (arg.Value is not null) + { + result.Add( + NameConstants.Name, + arg.Value.ToString()); + } + } + + foreach (var arg in attributeData.NamedArguments) + { + if (arg.Value.Kind == TypedConstantKind.Array) + { + foreach (var typedConstant in arg.Value.Values) + { + if (typedConstant.Value is null) + { + continue; + } + + arrayIndex++; + result.Add( + arrayIndex.ToString(CultureInfo.InvariantCulture), + typedConstant.Value.ToString()); + } + } + else + { + result.Add( + arg.Key, + arg.Value.Value?.ToString()); + } + } + + return result; + } } \ No newline at end of file