diff --git a/src/libs/DependencyPropertyGenerator/Generators/StaticConstructorGenerator.cs b/src/libs/DependencyPropertyGenerator/Generators/StaticConstructorGenerator.cs index ae363f3..98c678b 100644 --- a/src/libs/DependencyPropertyGenerator/Generators/StaticConstructorGenerator.cs +++ b/src/libs/DependencyPropertyGenerator/Generators/StaticConstructorGenerator.cs @@ -1,4 +1,5 @@ -using H.Generators.Extensions; +using System.Collections.Immutable; +using H.Generators.Extensions; using Microsoft.CodeAnalysis; namespace H.Generators; @@ -32,55 +33,47 @@ public void Initialize(IncrementalGeneratorInitializationContext context) var framework = context.DetectFramework(); var version = context.DetectVersion(); - context.SyntaxProvider + var dp1 = context.SyntaxProvider .ForAttributeWithMetadataNameOfClassesAndRecords("DependencyPropertyGenerator.DependencyPropertyAttribute") .SelectManyAllAttributesOfCurrentClassSyntax() .Combine(framework) .Combine(version) .SelectAndReportExceptions(static (x, _) => PrepareData(x, isAttached: false), context, Id) .WhereNotNull() - .CollectAsEquatableArray() - .SelectAndReportExceptions(GetSourceCode, context, Id) - .AddSource(context); - context.SyntaxProvider + .CollectAsEquatableArray(); + + var dp2 = context.SyntaxProvider .ForAttributeWithMetadataNameOfClassesAndRecords("DependencyPropertyGenerator.DependencyPropertyAttribute`1") .SelectManyAllAttributesOfCurrentClassSyntax() .Combine(framework) .Combine(version) .SelectAndReportExceptions(static (x, _) => PrepareData(x, isAttached: false), context, Id) .WhereNotNull() - .CollectAsEquatableArray() - .SelectAndReportExceptions(GetSourceCode, context, Id) - .AddSource(context); - context.SyntaxProvider + .CollectAsEquatableArray(); + + var adp1 = context.SyntaxProvider .ForAttributeWithMetadataNameOfClassesAndRecords("DependencyPropertyGenerator.AttachedDependencyPropertyAttribute") .SelectManyAllAttributesOfCurrentClassSyntax() .Combine(framework) .Combine(version) .SelectAndReportExceptions(static (x, _) => PrepareData(x, isAttached: true), context, Id) .WhereNotNull() - .CollectAsEquatableArray() - .SelectAndReportExceptions(GetSourceCode, context, Id) - .AddSource(context); - context.SyntaxProvider - .ForAttributeWithMetadataNameOfClassesAndRecords("DependencyPropertyGenerator.AttachedDependencyPropertyAttribute`1") - .SelectManyAllAttributesOfCurrentClassSyntax() - .Combine(framework) - .Combine(version) - .SelectAndReportExceptions(static (x, _) => PrepareData(x, isAttached: true), context, Id) - .WhereNotNull() - .CollectAsEquatableArray() - .SelectAndReportExceptions(GetSourceCode, context, Id) - .AddSource(context); - context.SyntaxProvider + .CollectAsEquatableArray(); + + var adp2 = context.SyntaxProvider .ForAttributeWithMetadataNameOfClassesAndRecords("DependencyPropertyGenerator.AttachedDependencyPropertyAttribute`2") .SelectManyAllAttributesOfCurrentClassSyntax() .Combine(framework) .Combine(version) .SelectAndReportExceptions(static (x, _) => PrepareData(x, isAttached: true), context, Id) .WhereNotNull() - .CollectAsEquatableArray() - .SelectAndReportExceptions(GetSourceCode, context, Id) + .CollectAsEquatableArray(); + // A type can have only one static constructor, so combined all four attributes. + // Is there a better performance way? + dp1.Combine(dp2.Combine(adp1.Combine(adp2))).Select((x, _) => + { + return x.Left.AsImmutableArray().AddRange(x.Right.Left).AddRange(x.Right.Right.Left).AddRange(x.Right.Right.Right).AsEquatableArray(); + }).SelectAndReportExceptions(GetSourceCode, context, Id) .AddSource(context); } @@ -102,40 +95,31 @@ private static (ClassData Class, DependencyPropertyData DependencyProperty)? Pre return (classData, dependencyPropertyData); } - private static FileWithName GetSourceCode( + private static EquatableArray GetSourceCode( EquatableArray<(ClassData Class, DependencyPropertyData DependencyProperty)> values) { if (values.AsImmutableArray().IsDefaultOrEmpty) { - return FileWithName.Empty; - } - - var @class = values.First().Class; - if (@class.Framework is not Framework.Avalonia) - { - return FileWithName.Empty; + return ImmutableArray.Empty.AsEquatableArray(); } - var dependencyProperties = values - .Select(static x => x.DependencyProperty) - .ToArray(); - if (dependencyProperties.Where(static property => !property.IsDirect).Any()) + return values.Where(x => x.Class.Framework is Framework.Avalonia).GroupBy(x => x.Class, x => x.DependencyProperty).Select(a => { var text = Sources.GenerateStaticConstructor( - @class, - dependencyProperties - .Where(static property => !property.IsDirect) + a.Key, + a.Where(static property => !property.IsDirect) .ToArray()); - if (!string.IsNullOrWhiteSpace(text)) { return new FileWithName( - Name: $"{@class.FullName}.StaticConstructor.g.cs", + Name: $"{a.Key.FullName}.StaticConstructor.g.cs", Text: text); } - } - - return FileWithName.Empty; + else + { + return FileWithName.Empty; + } + }).ToImmutableArray().AsEquatableArray(); } #endregion diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/Tests.MultiTypesInOne_Diagnostics.verified.txt b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/Tests.MultiTypesInOne_Diagnostics.verified.txt new file mode 100644 index 0000000..d64986f --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/Tests.MultiTypesInOne_Diagnostics.verified.txt @@ -0,0 +1,17 @@ +[ + { + Id: CS8019, + Title: Unnecessary using directive, + Severity: Hidden, + WarningLevel: 1, + Location: : (0,0)-(0,15), + HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS8019), + MessageFormat: Unnecessary using directive., + Message: Unnecessary using directive., + Category: Compiler, + CustomTags: [ + Compiler, + Telemetry + ] + } +] \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#DefaultBindingMode.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#DefaultBindingMode.g.verified.cs new file mode 100644 index 0000000..75f72c3 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#DefaultBindingMode.g.verified.cs @@ -0,0 +1,58 @@ +//HintName: DefaultBindingMode.g.cs +#nullable enable + +namespace DependencyPropertyGenerator; + +/// +/// Describes the direction of the data flow in a binding. +/// +internal enum DefaultBindingMode +{ + /// + /// Causes changes to either the source property or the target property to automatically + /// update the other. This type of binding is appropriate for editable forms or other + /// fully-interactive UI scenarios. + /// + TwoWay = 0, + + /// + /// Updates the binding target (target) property when the binding source (source) + /// changes. This type of binding is appropriate if the control being bound is implicitly + /// read-only. For instance, you may bind to a source such as a stock ticker. Or + /// perhaps your target property has no control interface provided for making changes, + /// such as a data-bound background color of a table. If there is no need to monitor + /// the changes of the target property, using the System.Windows.Data.BindingMode.OneWay + /// binding mode avoids the overhead of the System.Windows.Data.BindingMode.TwoWay + /// binding mode. + /// + OneWay = 1, + + /// + /// Updates the binding target when the application starts or when the data context + /// changes. This type of binding is appropriate if you are using data where either + /// a snapshot of the current state is appropriate to use or the data is truly static. + /// This type of binding is also useful if you want to initialize your target property + /// with some value from a source property and the data context is not known in advance. + /// This is essentially a simpler form of System.Windows.Data.BindingMode.OneWay + /// binding that provides better performance in cases where the source value does + /// not change. + /// + OneTime = 2, + + /// + /// Updates the source property when the target property changes. + /// + OneWayToSource = 3, + + /// + /// Uses the default System.Windows.Data.Binding.Mode value of the binding target. + /// The default value varies for each dependency property. In general, user-editable + /// control properties, such as those of text boxes and check boxes, default to two-way + /// bindings, whereas most other properties default to one-way bindings. A programmatic + /// way to determine whether a dependency property binds one-way or two-way by default + /// is to get the property metadata of the property using System.Windows.DependencyProperty.GetMetadata(System.Type) + /// and then check the Boolean value of the System.Windows.FrameworkPropertyMetadata.BindsTwoWayByDefault + /// property. + /// + Default = 4, +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#DependencyPropertyAttribute.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#DependencyPropertyAttribute.g.verified.cs new file mode 100644 index 0000000..efcf6e7 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#DependencyPropertyAttribute.g.verified.cs @@ -0,0 +1,480 @@ +//HintName: DependencyPropertyAttribute.g.cs +// ReSharper disable RedundantNameQualifier +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global +#nullable enable + +namespace DependencyPropertyGenerator; + +/// +/// Generates attached dependency property using DependencyProperty.Register. +/// +[global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = true)] +[global::System.Diagnostics.Conditional("DEPENDENCY_PROPERTY_GENERATOR_ATTRIBUTES")] +internal sealed class DependencyPropertyAttribute : global::System.Attribute +{ + /// + /// Name of this dependency property. + /// + public string Name { get; } + + /// + /// Type of this dependency property. + /// + public global::System.Type Type { get; } + + /// + /// Default value of this dependency property.
+ /// If you need to pass a new() expression, use .
+ /// Default - . + ///
+ public object? DefaultValue { get; set; } + + /// + /// Default value expression of this dependency property.
+ /// Used to pass a new() expression to an initializer.
+ /// Default - . + ///
+ public string? DefaultValueExpression { get; set; } + + /// + /// The property will create through RegisterReadOnly (if the platform supports it) and + /// the property setter will contain the protected modifier.
+ /// Default - . + ///
+ public bool IsReadOnly { get; set; } + + /// + /// Avalonia: Direct properties are a lightweight version of styled properties.
+ /// Default - . + ///
+ public bool IsDirect { get; set; } + + /// + /// Description of this dependency property.
+ /// The property will contain a with this value.
+ /// This will also be used in the xml documentation if not explicitly specified.
+ /// Default - . + ///
+ public string? Description { get; set; } + + /// + /// Category of this dependency property.
+ /// The property will contain a with this value.
+ /// Default - . + ///
+ public string? Category { get; set; } + + /// + /// Type converter of this dependency property.
+ /// The property will contain a with this value.
+ /// Default - . + ///
+ public global::System.Type? TypeConverter { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool Bindable { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool Browsable { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public global::System.ComponentModel.DesignerSerializationVisibility DesignerSerializationVisibility { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool ClsCompliant { get; set; } + + /// + /// The property will contain a System.Windows.LocalizabilityAttribute with this value.
+ /// Default - . + ///
+ public Localizability Localizability { get; set; } + + /// + /// The dependency property xml documentation.
+ /// Default - "<summary></summary>". + ///
+ public string XmlDocumentation { get; set; } = string.Empty; + + /// + /// The property getter/setter xml documentation.
+ /// Default - "<summary></summary>". + ///
+ public string PropertyXmlDocumentation { get; set; } = string.Empty; + + /// + /// For values other than default(type), will bind/rebind/remove the + /// On{Name}Changed_{EventName}(object sender, Args args) handler for the specified event.
+ /// It is recommended to specify as nameof(UIElement.Drop).
+ /// Default - string.Empty. + ///
+ public string BindEvent { get; set; } = string.Empty; + + /// + /// For values other than default(type), will bind/rebind/remove the + /// On{Name}Changed_{EventName}(object sender, Args args) handler for the specified event.
+ /// It is recommended to specify as nameof(UIElement.Drop).
+ /// Default - . + ///
+ public string[]? BindEvents { get; set; } + + /// + /// Allows to set a custom name for the OnChanged method call, allowing this method to be non-partial. + /// + public string OnChanged { get; set; } = string.Empty; + + /// + /// WPF: The measure pass of layout compositions is affected by value changes to this dependency property. + /// + public bool AffectsMeasure { get; set; } + + /// + /// WPF: The arrange pass of layout composition is affected by value changes to this dependency property. + /// + public bool AffectsArrange { get; set; } + + /// + /// WPF: The measure pass on the parent element is affected by value changes to this dependency property. + /// + public bool AffectsParentMeasure { get; set; } + + /// + /// WPF: The arrange pass on the parent element is affected by value changes to this dependency property. + /// + public bool AffectsParentArrange { get; set; } + + /// + /// WPF: Some aspect of rendering or layout composition (other than measure or arrange) is affected by value changes to this dependency property. + /// + public bool AffectsRender { get; set; } + + /// + /// WPF: The values of this dependency property are inherited by child elements. + /// + public bool Inherits { get; set; } + + /// + /// WPF: The values of this dependency property span separated trees for purposes of property value inheritance. + /// + public bool OverridesInheritanceBehavior { get; set; } + + /// + /// WPF: Data binding to this dependency property is not allowed. + /// + public bool NotDataBindable { get; set; } + + /// + /// WPF: The values of this dependency property should be saved or restored by journaling processes, or when navigating by Uniform resource identifiers (URIs). + /// + public bool Journal { get; set; } + + /// + /// WPF: The sub properties on the value of this dependency property do not affect any aspect of rendering. + /// + public bool SubPropertiesDoNotAffectRender { get; set; } + + /// + /// WPF: true to prevent the property system from animating the property that this metadata + /// is applied to. Such properties will raise a run-time exception originating from + /// the property system if animations of them are attempted. The default is false. + /// + public bool IsAnimationProhibited { get; set; } + + /// + /// WPF: The System.Windows.Data.UpdateSourceTrigger to use when bindings for this property + /// are applied that have their System.Windows.Data.UpdateSourceTrigger set to + /// System.Windows.Data.UpdateSourceTrigger.Default. + /// + public SourceTrigger DefaultUpdateSourceTrigger { get; set; } + + /// + /// Avalonia/MAUI: Default BindingMode.
+ /// WPF: Only Default/TwoWay is supported.
+ /// Default - . + ///
+ public DefaultBindingMode DefaultBindingMode { get; set; } = DefaultBindingMode.Default; + + /// + /// Avalonia-DirectProperty: Whether the property is interested in data validation.
+ /// Default - . + ///
+ public bool EnableDataValidation { get; set; } + + /// + /// WPF: partial method for coerceValueCallback will be created. + /// + public bool Coerce { get; set; } + + /// + /// WPF: partial method for validateValueCallback will be created.
+ /// Default - . + ///
+ public bool Validate { get; set; } + + /// + /// UWP/WinUI/Uno/MAUI: partial method for createDefaultValueCallback will be created. + /// + public bool CreateDefaultValueCallback { get; set; } + + /// + /// + /// + /// + /// + /// + public DependencyPropertyAttribute( + string name, + global::System.Type type) + { + Name = name ?? throw new global::System.ArgumentNullException(nameof(name)); + Type = type ?? throw new global::System.ArgumentNullException(nameof(type)); + } +} + +/// +/// Generates attached dependency property using DependencyProperty.Register. +/// +/// Type of this dependency property. +[global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = true)] +[global::System.Diagnostics.Conditional("DEPENDENCY_PROPERTY_GENERATOR_ATTRIBUTES")] +internal sealed class DependencyPropertyAttribute : global::System.Attribute +{ + /// + /// Name of this dependency property. + /// + public string Name { get; } + + /// + /// Type of this dependency property. + /// + public global::System.Type Type { get; } + + /// + /// Default value of this dependency property.
+ /// If you need to pass a new() expression, use .
+ /// Default - . + ///
+ public T? DefaultValue { get; set; } + + /// + /// Default value expression of this dependency property.
+ /// Used to pass a new() expression to an initializer.
+ /// Default - . + ///
+ public string? DefaultValueExpression { get; set; } + + /// + /// The property will create through RegisterReadOnly (if the platform supports it) and + /// the property setter will contain the protected modifier.
+ /// Default - . + ///
+ public bool IsReadOnly { get; set; } + + /// + /// Avalonia: Direct properties are a lightweight version of styled properties.
+ /// Default - . + ///
+ public bool IsDirect { get; set; } + + /// + /// Description of this dependency property.
+ /// The property will contain a with this value.
+ /// This will also be used in the xml documentation if not explicitly specified.
+ /// Default - . + ///
+ public string? Description { get; set; } + + /// + /// Category of this dependency property.
+ /// The property will contain a with this value.
+ /// Default - . + ///
+ public string? Category { get; set; } + + /// + /// Type converter of this dependency property.
+ /// The property will contain a with this value.
+ /// Default - . + ///
+ public global::System.Type? TypeConverter { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool Bindable { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool Browsable { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public global::System.ComponentModel.DesignerSerializationVisibility DesignerSerializationVisibility { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool ClsCompliant { get; set; } + + /// + /// The property will contain a System.Windows.LocalizabilityAttribute with this value.
+ /// Default - . + ///
+ public Localizability Localizability { get; set; } + + /// + /// The dependency property xml documentation.
+ /// Default - "<summary></summary>". + ///
+ public string XmlDocumentation { get; set; } = string.Empty; + + /// + /// The property getter/setter xml documentation.
+ /// Default - "<summary></summary>". + ///
+ public string PropertyXmlDocumentation { get; set; } = string.Empty; + + /// + /// For values other than default(type), will bind/rebind/remove the + /// On{Name}Changed_{EventName}(object sender, Args args) handler for the specified event.
+ /// It is recommended to specify as nameof(UIElement.Drop).
+ /// Default - string.Empty. + ///
+ public string BindEvent { get; set; } = string.Empty; + + /// + /// For values other than default(type), will bind/rebind/remove the + /// On{Name}Changed_{EventName}(object sender, Args args) handler for the specified event.
+ /// It is recommended to specify as nameof(UIElement.Drop).
+ /// Default - . + ///
+ public string[]? BindEvents { get; set; } + + /// + /// Allows to set a custom name for the OnChanged method call, allowing this method to be non-partial. + /// + public string OnChanged { get; set; } = string.Empty; + + /// + /// WPF: The measure pass of layout compositions is affected by value changes to this dependency property. + /// + public bool AffectsMeasure { get; set; } + + /// + /// WPF: The arrange pass of layout composition is affected by value changes to this dependency property. + /// + public bool AffectsArrange { get; set; } + + /// + /// WPF: The measure pass on the parent element is affected by value changes to this dependency property. + /// + public bool AffectsParentMeasure { get; set; } + + /// + /// WPF: The arrange pass on the parent element is affected by value changes to this dependency property. + /// + public bool AffectsParentArrange { get; set; } + + /// + /// WPF: Some aspect of rendering or layout composition (other than measure or arrange) is affected by value changes to this dependency property. + /// + public bool AffectsRender { get; set; } + + /// + /// WPF: The values of this dependency property are inherited by child elements. + /// + public bool Inherits { get; set; } + + /// + /// WPF: The values of this dependency property span separated trees for purposes of property value inheritance. + /// + public bool OverridesInheritanceBehavior { get; set; } + + /// + /// WPF: Data binding to this dependency property is not allowed. + /// + public bool NotDataBindable { get; set; } + + /// + /// WPF: The values of this dependency property should be saved or restored by journaling processes, or when navigating by Uniform resource identifiers (URIs). + /// + public bool Journal { get; set; } + + /// + /// WPF: The sub properties on the value of this dependency property do not affect any aspect of rendering. + /// + public bool SubPropertiesDoNotAffectRender { get; set; } + + /// + /// WPF: true to prevent the property system from animating the property that this metadata + /// is applied to. Such properties will raise a run-time exception originating from + /// the property system if animations of them are attempted. The default is false. + /// + public bool IsAnimationProhibited { get; set; } + + /// + /// WPF: The System.Windows.Data.UpdateSourceTrigger to use when bindings for this property + /// are applied that have their System.Windows.Data.UpdateSourceTrigger set to + /// System.Windows.Data.UpdateSourceTrigger.Default. + /// + public SourceTrigger DefaultUpdateSourceTrigger { get; set; } + + /// + /// Avalonia/MAUI: Default BindingMode.
+ /// WPF: Only Default/TwoWay is supported.
+ /// Default - . + ///
+ public DefaultBindingMode DefaultBindingMode { get; set; } = DefaultBindingMode.Default; + + /// + /// Avalonia-DirectProperty: Whether the property is interested in data validation.
+ /// Default - . + ///
+ public bool EnableDataValidation { get; set; } + + /// + /// WPF: partial method for coerceValueCallback will be created. + /// + public bool Coerce { get; set; } + + /// + /// WPF: partial method for validateValueCallback will be created.
+ /// Default - . + ///
+ public bool Validate { get; set; } + + /// + /// UWP/WinUI/Uno/MAUI: partial method for createDefaultValueCallback will be created. + /// + public bool CreateDefaultValueCallback { get; set; } + + /// + /// + /// + /// + /// + public DependencyPropertyAttribute( + string name) + { + Name = name ?? throw new global::System.ArgumentNullException(nameof(name)); + Type = typeof(T); + } +} diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty.g.verified.cs new file mode 100644 index 0000000..6da70f9 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty.g.verified.cs @@ -0,0 +1,41 @@ +//HintName: H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class AnotherControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Avalonia.StyledProperty MyPropertyProperty = + global::Avalonia.AvaloniaProperty.Register( + name: "MyProperty", + defaultValue: default(int), + inherits: false, + defaultBindingMode: global::Avalonia.Data.BindingMode.OneWay, + validate: null, + coerce: null); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty + { + get => (int)GetValue(MyPropertyProperty); + set => SetValue(MyPropertyProperty, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty2.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty2.g.verified.cs new file mode 100644 index 0000000..76746de --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty2.g.verified.cs @@ -0,0 +1,41 @@ +//HintName: H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty2.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class AnotherControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default((int, string)) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Avalonia.StyledProperty<(int, string)> MyProperty2Property = + global::Avalonia.AvaloniaProperty.Register( + name: "MyProperty2", + defaultValue: default((int, string)), + inherits: false, + defaultBindingMode: global::Avalonia.Data.BindingMode.OneWay, + validate: null, + coerce: null); + + /// + /// Default value: default((int, string)) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public (int, string) MyProperty2 + { + get => ((int, string))GetValue(MyProperty2Property); + set => SetValue(MyProperty2Property, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed((int, string) newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed((int, string) oldValue, (int, string) newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty3.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty3.g.verified.cs new file mode 100644 index 0000000..9640f67 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty3.g.verified.cs @@ -0,0 +1,41 @@ +//HintName: H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty3.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class AnotherControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Avalonia.StyledProperty MyProperty3Property = + global::Avalonia.AvaloniaProperty.Register( + name: "MyProperty3", + defaultValue: default(int), + inherits: false, + defaultBindingMode: global::Avalonia.Data.BindingMode.OneWay, + validate: null, + coerce: null); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty3 + { + get => (int)GetValue(MyProperty3Property); + set => SetValue(MyProperty3Property, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.AnotherControl.StaticConstructor.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.AnotherControl.StaticConstructor.g.verified.cs new file mode 100644 index 0000000..d911204 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.AnotherControl.StaticConstructor.g.verified.cs @@ -0,0 +1,26 @@ +//HintName: H.Generators.IntegrationTests.AnotherControl.StaticConstructor.g.cs +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class AnotherControl + { + static AnotherControl() + { + MyProperty3Property.Changed.Subscribe(new global::Avalonia.Reactive.AnonymousObserver>(static x => + { + ((global::H.Generators.IntegrationTests.AnotherControl)x.Sender).OnMyProperty3Changed(); + })); + + MyPropertyProperty.Changed.Subscribe(new global::Avalonia.Reactive.AnonymousObserver>(static x => + { + ((global::H.Generators.IntegrationTests.AnotherControl)x.Sender).OnMyPropertyChanged(); + })); + + MyProperty2Property.Changed.Subscribe(new global::Avalonia.Reactive.AnonymousObserver>(static x => + { + ((global::H.Generators.IntegrationTests.AnotherControl)x.Sender).OnMyProperty2Changed(); + })); + } + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty.g.verified.cs new file mode 100644 index 0000000..916eb63 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty.g.verified.cs @@ -0,0 +1,41 @@ +//HintName: H.Generators.IntegrationTests.MyControl.Properties.MyProperty.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class MyControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Avalonia.StyledProperty MyPropertyProperty = + global::Avalonia.AvaloniaProperty.Register( + name: "MyProperty", + defaultValue: default(int), + inherits: false, + defaultBindingMode: global::Avalonia.Data.BindingMode.OneWay, + validate: null, + coerce: null); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty + { + get => (int)GetValue(MyPropertyProperty); + set => SetValue(MyPropertyProperty, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty2.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty2.g.verified.cs new file mode 100644 index 0000000..cd23ea6 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty2.g.verified.cs @@ -0,0 +1,41 @@ +//HintName: H.Generators.IntegrationTests.MyControl.Properties.MyProperty2.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class MyControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Avalonia.StyledProperty MyProperty2Property = + global::Avalonia.AvaloniaProperty.Register( + name: "MyProperty2", + defaultValue: default(int), + inherits: false, + defaultBindingMode: global::Avalonia.Data.BindingMode.OneWay, + validate: null, + coerce: null); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty2 + { + get => (int)GetValue(MyProperty2Property); + set => SetValue(MyProperty2Property, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty3.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty3.g.verified.cs new file mode 100644 index 0000000..a5c3934 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty3.g.verified.cs @@ -0,0 +1,41 @@ +//HintName: H.Generators.IntegrationTests.MyControl.Properties.MyProperty3.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class MyControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Avalonia.StyledProperty MyProperty3Property = + global::Avalonia.AvaloniaProperty.Register( + name: "MyProperty3", + defaultValue: default(int), + inherits: false, + defaultBindingMode: global::Avalonia.Data.BindingMode.OneWay, + validate: null, + coerce: null); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty3 + { + get => (int)GetValue(MyProperty3Property); + set => SetValue(MyProperty3Property, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.MyControl.StaticConstructor.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.MyControl.StaticConstructor.g.verified.cs new file mode 100644 index 0000000..8aa75f4 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#H.Generators.IntegrationTests.MyControl.StaticConstructor.g.verified.cs @@ -0,0 +1,26 @@ +//HintName: H.Generators.IntegrationTests.MyControl.StaticConstructor.g.cs +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class MyControl + { + static MyControl() + { + MyProperty3Property.Changed.Subscribe(new global::Avalonia.Reactive.AnonymousObserver>(static x => + { + ((global::H.Generators.IntegrationTests.MyControl)x.Sender).OnMyProperty3Changed(); + })); + + MyPropertyProperty.Changed.Subscribe(new global::Avalonia.Reactive.AnonymousObserver>(static x => + { + ((global::H.Generators.IntegrationTests.MyControl)x.Sender).OnMyPropertyChanged(); + })); + + MyProperty2Property.Changed.Subscribe(new global::Avalonia.Reactive.AnonymousObserver>(static x => + { + ((global::H.Generators.IntegrationTests.MyControl)x.Sender).OnMyProperty2Changed(); + })); + } + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#Localizability.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#Localizability.g.verified.cs new file mode 100644 index 0000000..e06ac0e --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#Localizability.g.verified.cs @@ -0,0 +1,101 @@ +//HintName: Localizability.g.cs +#nullable enable + +namespace DependencyPropertyGenerator; + +/// +/// Specifies the category value of a System.Windows.LocalizabilityAttribute +/// for a binary XAML (BAML) class or class member. +/// +internal enum Localizability +{ + /// + /// Resource does not belong to a standard category. + /// + None, + + /// + /// For a lengthy piece of text. + /// + Text, + + /// + /// For a single line of text, such as text used for a title. + /// + Title, + + /// + /// A System.Windows.Controls.Label or related control. + /// + Label, + + /// + /// A System.Windows.Controls.Button or related control. + /// + Button, + + /// + /// A System.Windows.Controls.CheckBox or related control. + /// + CheckBox, + + /// + /// A System.Windows.Controls.ComboBox or related control such as System.Windows.Controls.ComboBoxItem. + /// + ComboBox, + + /// + /// A System.Windows.Controls.ListBox or related control such as System.Windows.Controls.ListBoxItem. + /// + ListBox, + + /// + /// A System.Windows.Controls.Menu or related control such as System.Windows.Controls.MenuItem. + /// + Menu, + + /// + /// A System.Windows.Controls.RadioButton or related control. + /// + RadioButton, + + /// + /// A System.Windows.Controls.ToolTip or related control. + /// + ToolTip, + + /// + /// A System.Windows.Documents.Hyperlink or related control. + /// + Hyperlink, + + /// + /// For panels that can contain text. + /// + TextFlow, + + /// + /// XML data. + /// + XmlData, + + /// + /// Font-related data such as font name, style, or size. + /// + Font, + + /// + /// Inherits its category from a parent node. + /// + Inherit, + + /// + /// Do not localize this resource. This does not apply to any child nodes that might exist. + /// + Ignore, + + /// + /// Do not localize this resource, or any child nodes whose category is set to Inherit. + /// + NeverLocalize, +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#SourceTrigger.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#SourceTrigger.g.verified.cs new file mode 100644 index 0000000..0f720ad --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Avalonia/_#SourceTrigger.g.verified.cs @@ -0,0 +1,34 @@ +//HintName: SourceTrigger.g.cs +#nullable enable + +namespace DependencyPropertyGenerator; + +/// +/// Describes the timing of binding source updates. +/// +internal enum SourceTrigger +{ + /// + /// The default System.Windows.Data.UpdateSourceTrigger value of the binding target + /// property. The default value for most dependency properties is + /// System.Windows.Data.UpdateSourceTrigger.PropertyChanged, + /// while the System.Windows.Controls.TextBox.Text property has a default value of + /// System.Windows.Data.UpdateSourceTrigger.LostFocus. + /// + Default = 0, + + /// + /// Updates the binding source immediately whenever the binding target property changes. + /// + PropertyChanged = 1, + + /// + /// Updates the binding source whenever the binding target element loses focus. + /// + LostFocus = 2, + + /// + /// Updates the binding source only when you call the System.Windows.Data.BindingExpression.UpdateSource method. + /// + Explicit = 3, +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/Tests.MultiTypesInOne_Diagnostics.verified.txt b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/Tests.MultiTypesInOne_Diagnostics.verified.txt new file mode 100644 index 0000000..4dd487e --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/Tests.MultiTypesInOne_Diagnostics.verified.txt @@ -0,0 +1,17 @@ +[ + { + Id: CS8019, + Title: Unnecessary using directive, + Severity: Hidden, + WarningLevel: 1, + Location: : (1,0)-(1,21), + HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS8019), + MessageFormat: Unnecessary using directive., + Message: Unnecessary using directive., + Category: Compiler, + CustomTags: [ + Compiler, + Telemetry + ] + } +] \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#DefaultBindingMode.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#DefaultBindingMode.g.verified.cs new file mode 100644 index 0000000..75f72c3 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#DefaultBindingMode.g.verified.cs @@ -0,0 +1,58 @@ +//HintName: DefaultBindingMode.g.cs +#nullable enable + +namespace DependencyPropertyGenerator; + +/// +/// Describes the direction of the data flow in a binding. +/// +internal enum DefaultBindingMode +{ + /// + /// Causes changes to either the source property or the target property to automatically + /// update the other. This type of binding is appropriate for editable forms or other + /// fully-interactive UI scenarios. + /// + TwoWay = 0, + + /// + /// Updates the binding target (target) property when the binding source (source) + /// changes. This type of binding is appropriate if the control being bound is implicitly + /// read-only. For instance, you may bind to a source such as a stock ticker. Or + /// perhaps your target property has no control interface provided for making changes, + /// such as a data-bound background color of a table. If there is no need to monitor + /// the changes of the target property, using the System.Windows.Data.BindingMode.OneWay + /// binding mode avoids the overhead of the System.Windows.Data.BindingMode.TwoWay + /// binding mode. + /// + OneWay = 1, + + /// + /// Updates the binding target when the application starts or when the data context + /// changes. This type of binding is appropriate if you are using data where either + /// a snapshot of the current state is appropriate to use or the data is truly static. + /// This type of binding is also useful if you want to initialize your target property + /// with some value from a source property and the data context is not known in advance. + /// This is essentially a simpler form of System.Windows.Data.BindingMode.OneWay + /// binding that provides better performance in cases where the source value does + /// not change. + /// + OneTime = 2, + + /// + /// Updates the source property when the target property changes. + /// + OneWayToSource = 3, + + /// + /// Uses the default System.Windows.Data.Binding.Mode value of the binding target. + /// The default value varies for each dependency property. In general, user-editable + /// control properties, such as those of text boxes and check boxes, default to two-way + /// bindings, whereas most other properties default to one-way bindings. A programmatic + /// way to determine whether a dependency property binds one-way or two-way by default + /// is to get the property metadata of the property using System.Windows.DependencyProperty.GetMetadata(System.Type) + /// and then check the Boolean value of the System.Windows.FrameworkPropertyMetadata.BindsTwoWayByDefault + /// property. + /// + Default = 4, +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#DependencyPropertyAttribute.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#DependencyPropertyAttribute.g.verified.cs new file mode 100644 index 0000000..efcf6e7 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#DependencyPropertyAttribute.g.verified.cs @@ -0,0 +1,480 @@ +//HintName: DependencyPropertyAttribute.g.cs +// ReSharper disable RedundantNameQualifier +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global +#nullable enable + +namespace DependencyPropertyGenerator; + +/// +/// Generates attached dependency property using DependencyProperty.Register. +/// +[global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = true)] +[global::System.Diagnostics.Conditional("DEPENDENCY_PROPERTY_GENERATOR_ATTRIBUTES")] +internal sealed class DependencyPropertyAttribute : global::System.Attribute +{ + /// + /// Name of this dependency property. + /// + public string Name { get; } + + /// + /// Type of this dependency property. + /// + public global::System.Type Type { get; } + + /// + /// Default value of this dependency property.
+ /// If you need to pass a new() expression, use .
+ /// Default - . + ///
+ public object? DefaultValue { get; set; } + + /// + /// Default value expression of this dependency property.
+ /// Used to pass a new() expression to an initializer.
+ /// Default - . + ///
+ public string? DefaultValueExpression { get; set; } + + /// + /// The property will create through RegisterReadOnly (if the platform supports it) and + /// the property setter will contain the protected modifier.
+ /// Default - . + ///
+ public bool IsReadOnly { get; set; } + + /// + /// Avalonia: Direct properties are a lightweight version of styled properties.
+ /// Default - . + ///
+ public bool IsDirect { get; set; } + + /// + /// Description of this dependency property.
+ /// The property will contain a with this value.
+ /// This will also be used in the xml documentation if not explicitly specified.
+ /// Default - . + ///
+ public string? Description { get; set; } + + /// + /// Category of this dependency property.
+ /// The property will contain a with this value.
+ /// Default - . + ///
+ public string? Category { get; set; } + + /// + /// Type converter of this dependency property.
+ /// The property will contain a with this value.
+ /// Default - . + ///
+ public global::System.Type? TypeConverter { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool Bindable { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool Browsable { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public global::System.ComponentModel.DesignerSerializationVisibility DesignerSerializationVisibility { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool ClsCompliant { get; set; } + + /// + /// The property will contain a System.Windows.LocalizabilityAttribute with this value.
+ /// Default - . + ///
+ public Localizability Localizability { get; set; } + + /// + /// The dependency property xml documentation.
+ /// Default - "<summary></summary>". + ///
+ public string XmlDocumentation { get; set; } = string.Empty; + + /// + /// The property getter/setter xml documentation.
+ /// Default - "<summary></summary>". + ///
+ public string PropertyXmlDocumentation { get; set; } = string.Empty; + + /// + /// For values other than default(type), will bind/rebind/remove the + /// On{Name}Changed_{EventName}(object sender, Args args) handler for the specified event.
+ /// It is recommended to specify as nameof(UIElement.Drop).
+ /// Default - string.Empty. + ///
+ public string BindEvent { get; set; } = string.Empty; + + /// + /// For values other than default(type), will bind/rebind/remove the + /// On{Name}Changed_{EventName}(object sender, Args args) handler for the specified event.
+ /// It is recommended to specify as nameof(UIElement.Drop).
+ /// Default - . + ///
+ public string[]? BindEvents { get; set; } + + /// + /// Allows to set a custom name for the OnChanged method call, allowing this method to be non-partial. + /// + public string OnChanged { get; set; } = string.Empty; + + /// + /// WPF: The measure pass of layout compositions is affected by value changes to this dependency property. + /// + public bool AffectsMeasure { get; set; } + + /// + /// WPF: The arrange pass of layout composition is affected by value changes to this dependency property. + /// + public bool AffectsArrange { get; set; } + + /// + /// WPF: The measure pass on the parent element is affected by value changes to this dependency property. + /// + public bool AffectsParentMeasure { get; set; } + + /// + /// WPF: The arrange pass on the parent element is affected by value changes to this dependency property. + /// + public bool AffectsParentArrange { get; set; } + + /// + /// WPF: Some aspect of rendering or layout composition (other than measure or arrange) is affected by value changes to this dependency property. + /// + public bool AffectsRender { get; set; } + + /// + /// WPF: The values of this dependency property are inherited by child elements. + /// + public bool Inherits { get; set; } + + /// + /// WPF: The values of this dependency property span separated trees for purposes of property value inheritance. + /// + public bool OverridesInheritanceBehavior { get; set; } + + /// + /// WPF: Data binding to this dependency property is not allowed. + /// + public bool NotDataBindable { get; set; } + + /// + /// WPF: The values of this dependency property should be saved or restored by journaling processes, or when navigating by Uniform resource identifiers (URIs). + /// + public bool Journal { get; set; } + + /// + /// WPF: The sub properties on the value of this dependency property do not affect any aspect of rendering. + /// + public bool SubPropertiesDoNotAffectRender { get; set; } + + /// + /// WPF: true to prevent the property system from animating the property that this metadata + /// is applied to. Such properties will raise a run-time exception originating from + /// the property system if animations of them are attempted. The default is false. + /// + public bool IsAnimationProhibited { get; set; } + + /// + /// WPF: The System.Windows.Data.UpdateSourceTrigger to use when bindings for this property + /// are applied that have their System.Windows.Data.UpdateSourceTrigger set to + /// System.Windows.Data.UpdateSourceTrigger.Default. + /// + public SourceTrigger DefaultUpdateSourceTrigger { get; set; } + + /// + /// Avalonia/MAUI: Default BindingMode.
+ /// WPF: Only Default/TwoWay is supported.
+ /// Default - . + ///
+ public DefaultBindingMode DefaultBindingMode { get; set; } = DefaultBindingMode.Default; + + /// + /// Avalonia-DirectProperty: Whether the property is interested in data validation.
+ /// Default - . + ///
+ public bool EnableDataValidation { get; set; } + + /// + /// WPF: partial method for coerceValueCallback will be created. + /// + public bool Coerce { get; set; } + + /// + /// WPF: partial method for validateValueCallback will be created.
+ /// Default - . + ///
+ public bool Validate { get; set; } + + /// + /// UWP/WinUI/Uno/MAUI: partial method for createDefaultValueCallback will be created. + /// + public bool CreateDefaultValueCallback { get; set; } + + /// + /// + /// + /// + /// + /// + public DependencyPropertyAttribute( + string name, + global::System.Type type) + { + Name = name ?? throw new global::System.ArgumentNullException(nameof(name)); + Type = type ?? throw new global::System.ArgumentNullException(nameof(type)); + } +} + +/// +/// Generates attached dependency property using DependencyProperty.Register. +/// +/// Type of this dependency property. +[global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = true)] +[global::System.Diagnostics.Conditional("DEPENDENCY_PROPERTY_GENERATOR_ATTRIBUTES")] +internal sealed class DependencyPropertyAttribute : global::System.Attribute +{ + /// + /// Name of this dependency property. + /// + public string Name { get; } + + /// + /// Type of this dependency property. + /// + public global::System.Type Type { get; } + + /// + /// Default value of this dependency property.
+ /// If you need to pass a new() expression, use .
+ /// Default - . + ///
+ public T? DefaultValue { get; set; } + + /// + /// Default value expression of this dependency property.
+ /// Used to pass a new() expression to an initializer.
+ /// Default - . + ///
+ public string? DefaultValueExpression { get; set; } + + /// + /// The property will create through RegisterReadOnly (if the platform supports it) and + /// the property setter will contain the protected modifier.
+ /// Default - . + ///
+ public bool IsReadOnly { get; set; } + + /// + /// Avalonia: Direct properties are a lightweight version of styled properties.
+ /// Default - . + ///
+ public bool IsDirect { get; set; } + + /// + /// Description of this dependency property.
+ /// The property will contain a with this value.
+ /// This will also be used in the xml documentation if not explicitly specified.
+ /// Default - . + ///
+ public string? Description { get; set; } + + /// + /// Category of this dependency property.
+ /// The property will contain a with this value.
+ /// Default - . + ///
+ public string? Category { get; set; } + + /// + /// Type converter of this dependency property.
+ /// The property will contain a with this value.
+ /// Default - . + ///
+ public global::System.Type? TypeConverter { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool Bindable { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool Browsable { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public global::System.ComponentModel.DesignerSerializationVisibility DesignerSerializationVisibility { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool ClsCompliant { get; set; } + + /// + /// The property will contain a System.Windows.LocalizabilityAttribute with this value.
+ /// Default - . + ///
+ public Localizability Localizability { get; set; } + + /// + /// The dependency property xml documentation.
+ /// Default - "<summary></summary>". + ///
+ public string XmlDocumentation { get; set; } = string.Empty; + + /// + /// The property getter/setter xml documentation.
+ /// Default - "<summary></summary>". + ///
+ public string PropertyXmlDocumentation { get; set; } = string.Empty; + + /// + /// For values other than default(type), will bind/rebind/remove the + /// On{Name}Changed_{EventName}(object sender, Args args) handler for the specified event.
+ /// It is recommended to specify as nameof(UIElement.Drop).
+ /// Default - string.Empty. + ///
+ public string BindEvent { get; set; } = string.Empty; + + /// + /// For values other than default(type), will bind/rebind/remove the + /// On{Name}Changed_{EventName}(object sender, Args args) handler for the specified event.
+ /// It is recommended to specify as nameof(UIElement.Drop).
+ /// Default - . + ///
+ public string[]? BindEvents { get; set; } + + /// + /// Allows to set a custom name for the OnChanged method call, allowing this method to be non-partial. + /// + public string OnChanged { get; set; } = string.Empty; + + /// + /// WPF: The measure pass of layout compositions is affected by value changes to this dependency property. + /// + public bool AffectsMeasure { get; set; } + + /// + /// WPF: The arrange pass of layout composition is affected by value changes to this dependency property. + /// + public bool AffectsArrange { get; set; } + + /// + /// WPF: The measure pass on the parent element is affected by value changes to this dependency property. + /// + public bool AffectsParentMeasure { get; set; } + + /// + /// WPF: The arrange pass on the parent element is affected by value changes to this dependency property. + /// + public bool AffectsParentArrange { get; set; } + + /// + /// WPF: Some aspect of rendering or layout composition (other than measure or arrange) is affected by value changes to this dependency property. + /// + public bool AffectsRender { get; set; } + + /// + /// WPF: The values of this dependency property are inherited by child elements. + /// + public bool Inherits { get; set; } + + /// + /// WPF: The values of this dependency property span separated trees for purposes of property value inheritance. + /// + public bool OverridesInheritanceBehavior { get; set; } + + /// + /// WPF: Data binding to this dependency property is not allowed. + /// + public bool NotDataBindable { get; set; } + + /// + /// WPF: The values of this dependency property should be saved or restored by journaling processes, or when navigating by Uniform resource identifiers (URIs). + /// + public bool Journal { get; set; } + + /// + /// WPF: The sub properties on the value of this dependency property do not affect any aspect of rendering. + /// + public bool SubPropertiesDoNotAffectRender { get; set; } + + /// + /// WPF: true to prevent the property system from animating the property that this metadata + /// is applied to. Such properties will raise a run-time exception originating from + /// the property system if animations of them are attempted. The default is false. + /// + public bool IsAnimationProhibited { get; set; } + + /// + /// WPF: The System.Windows.Data.UpdateSourceTrigger to use when bindings for this property + /// are applied that have their System.Windows.Data.UpdateSourceTrigger set to + /// System.Windows.Data.UpdateSourceTrigger.Default. + /// + public SourceTrigger DefaultUpdateSourceTrigger { get; set; } + + /// + /// Avalonia/MAUI: Default BindingMode.
+ /// WPF: Only Default/TwoWay is supported.
+ /// Default - . + ///
+ public DefaultBindingMode DefaultBindingMode { get; set; } = DefaultBindingMode.Default; + + /// + /// Avalonia-DirectProperty: Whether the property is interested in data validation.
+ /// Default - . + ///
+ public bool EnableDataValidation { get; set; } + + /// + /// WPF: partial method for coerceValueCallback will be created. + /// + public bool Coerce { get; set; } + + /// + /// WPF: partial method for validateValueCallback will be created.
+ /// Default - . + ///
+ public bool Validate { get; set; } + + /// + /// UWP/WinUI/Uno/MAUI: partial method for createDefaultValueCallback will be created. + /// + public bool CreateDefaultValueCallback { get; set; } + + /// + /// + /// + /// + /// + public DependencyPropertyAttribute( + string name) + { + Name = name ?? throw new global::System.ArgumentNullException(nameof(name)); + Type = typeof(T); + } +} diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty.g.verified.cs new file mode 100644 index 0000000..30dd0d4 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty.g.verified.cs @@ -0,0 +1,54 @@ +//HintName: H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class AnotherControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Microsoft.Maui.Controls.BindableProperty MyPropertyProperty = + global::Microsoft.Maui.Controls.BindableProperty.Create( + propertyName: "MyProperty", + returnType: typeof(int), + declaringType: typeof(global::H.Generators.IntegrationTests.AnotherControl), + defaultValue: default(int), + defaultBindingMode: global::Microsoft.Maui.Controls.BindingMode.OneWay, + validateValue: null, + propertyChanged: static (sender, oldValue, newValue) => + { + ((global::H.Generators.IntegrationTests.AnotherControl)sender).OnMyPropertyChanged(); + }, + propertyChanging: null, + coerceValue: null, + defaultValueCreator: null); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty + { + get => (int)GetValue(MyPropertyProperty); + set => SetValue(MyPropertyProperty, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(int oldValue, int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanging(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanging(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanging(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty2.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty2.g.verified.cs new file mode 100644 index 0000000..204ea5f --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty2.g.verified.cs @@ -0,0 +1,54 @@ +//HintName: H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty2.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class AnotherControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default((int, string)) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Microsoft.Maui.Controls.BindableProperty MyProperty2Property = + global::Microsoft.Maui.Controls.BindableProperty.Create( + propertyName: "MyProperty2", + returnType: typeof((int, string)), + declaringType: typeof(global::H.Generators.IntegrationTests.AnotherControl), + defaultValue: default((int, string)), + defaultBindingMode: global::Microsoft.Maui.Controls.BindingMode.OneWay, + validateValue: null, + propertyChanged: static (sender, oldValue, newValue) => + { + ((global::H.Generators.IntegrationTests.AnotherControl)sender).OnMyProperty2Changed(); + }, + propertyChanging: null, + coerceValue: null, + defaultValueCreator: null); + + /// + /// Default value: default((int, string)) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public (int, string) MyProperty2 + { + get => ((int, string))GetValue(MyProperty2Property); + set => SetValue(MyProperty2Property, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed((int, string) newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed((int, string) oldValue, (int, string) newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changing(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changing((int, string) newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changing((int, string) oldValue, (int, string) newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty3.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty3.g.verified.cs new file mode 100644 index 0000000..f3767d3 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty3.g.verified.cs @@ -0,0 +1,54 @@ +//HintName: H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty3.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class AnotherControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Microsoft.Maui.Controls.BindableProperty MyProperty3Property = + global::Microsoft.Maui.Controls.BindableProperty.Create( + propertyName: "MyProperty3", + returnType: typeof(int), + declaringType: typeof(global::H.Generators.IntegrationTests.AnotherControl), + defaultValue: default(int), + defaultBindingMode: global::Microsoft.Maui.Controls.BindingMode.OneWay, + validateValue: null, + propertyChanged: static (sender, oldValue, newValue) => + { + ((global::H.Generators.IntegrationTests.AnotherControl)sender).OnMyProperty3Changed(); + }, + propertyChanging: null, + coerceValue: null, + defaultValueCreator: null); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty3 + { + get => (int)GetValue(MyProperty3Property); + set => SetValue(MyProperty3Property, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(int oldValue, int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changing(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changing(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changing(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#H.Generators.IntegrationTests.MyGrid.Properties.MyProperty.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#H.Generators.IntegrationTests.MyGrid.Properties.MyProperty.g.verified.cs new file mode 100644 index 0000000..b8198ce --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#H.Generators.IntegrationTests.MyGrid.Properties.MyProperty.g.verified.cs @@ -0,0 +1,54 @@ +//HintName: H.Generators.IntegrationTests.MyGrid.Properties.MyProperty.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class MyGrid + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Microsoft.Maui.Controls.BindableProperty MyPropertyProperty = + global::Microsoft.Maui.Controls.BindableProperty.Create( + propertyName: "MyProperty", + returnType: typeof(int), + declaringType: typeof(global::H.Generators.IntegrationTests.MyGrid), + defaultValue: default(int), + defaultBindingMode: global::Microsoft.Maui.Controls.BindingMode.OneWay, + validateValue: null, + propertyChanged: static (sender, oldValue, newValue) => + { + ((global::H.Generators.IntegrationTests.MyGrid)sender).OnMyPropertyChanged(); + }, + propertyChanging: null, + coerceValue: null, + defaultValueCreator: null); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty + { + get => (int)GetValue(MyPropertyProperty); + set => SetValue(MyPropertyProperty, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(int oldValue, int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanging(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanging(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanging(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#H.Generators.IntegrationTests.MyGrid.Properties.MyProperty2.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#H.Generators.IntegrationTests.MyGrid.Properties.MyProperty2.g.verified.cs new file mode 100644 index 0000000..1b5935c --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#H.Generators.IntegrationTests.MyGrid.Properties.MyProperty2.g.verified.cs @@ -0,0 +1,54 @@ +//HintName: H.Generators.IntegrationTests.MyGrid.Properties.MyProperty2.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class MyGrid + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Microsoft.Maui.Controls.BindableProperty MyProperty2Property = + global::Microsoft.Maui.Controls.BindableProperty.Create( + propertyName: "MyProperty2", + returnType: typeof(int), + declaringType: typeof(global::H.Generators.IntegrationTests.MyGrid), + defaultValue: default(int), + defaultBindingMode: global::Microsoft.Maui.Controls.BindingMode.OneWay, + validateValue: null, + propertyChanged: static (sender, oldValue, newValue) => + { + ((global::H.Generators.IntegrationTests.MyGrid)sender).OnMyProperty2Changed(); + }, + propertyChanging: null, + coerceValue: null, + defaultValueCreator: null); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty2 + { + get => (int)GetValue(MyProperty2Property); + set => SetValue(MyProperty2Property, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed(int oldValue, int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changing(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changing(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changing(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#H.Generators.IntegrationTests.MyGrid.Properties.MyProperty3.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#H.Generators.IntegrationTests.MyGrid.Properties.MyProperty3.g.verified.cs new file mode 100644 index 0000000..84fb7d2 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#H.Generators.IntegrationTests.MyGrid.Properties.MyProperty3.g.verified.cs @@ -0,0 +1,54 @@ +//HintName: H.Generators.IntegrationTests.MyGrid.Properties.MyProperty3.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class MyGrid + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Microsoft.Maui.Controls.BindableProperty MyProperty3Property = + global::Microsoft.Maui.Controls.BindableProperty.Create( + propertyName: "MyProperty3", + returnType: typeof(int), + declaringType: typeof(global::H.Generators.IntegrationTests.MyGrid), + defaultValue: default(int), + defaultBindingMode: global::Microsoft.Maui.Controls.BindingMode.OneWay, + validateValue: null, + propertyChanged: static (sender, oldValue, newValue) => + { + ((global::H.Generators.IntegrationTests.MyGrid)sender).OnMyProperty3Changed(); + }, + propertyChanging: null, + coerceValue: null, + defaultValueCreator: null); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty3 + { + get => (int)GetValue(MyProperty3Property); + set => SetValue(MyProperty3Property, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(int oldValue, int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changing(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changing(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changing(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#Localizability.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#Localizability.g.verified.cs new file mode 100644 index 0000000..e06ac0e --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#Localizability.g.verified.cs @@ -0,0 +1,101 @@ +//HintName: Localizability.g.cs +#nullable enable + +namespace DependencyPropertyGenerator; + +/// +/// Specifies the category value of a System.Windows.LocalizabilityAttribute +/// for a binary XAML (BAML) class or class member. +/// +internal enum Localizability +{ + /// + /// Resource does not belong to a standard category. + /// + None, + + /// + /// For a lengthy piece of text. + /// + Text, + + /// + /// For a single line of text, such as text used for a title. + /// + Title, + + /// + /// A System.Windows.Controls.Label or related control. + /// + Label, + + /// + /// A System.Windows.Controls.Button or related control. + /// + Button, + + /// + /// A System.Windows.Controls.CheckBox or related control. + /// + CheckBox, + + /// + /// A System.Windows.Controls.ComboBox or related control such as System.Windows.Controls.ComboBoxItem. + /// + ComboBox, + + /// + /// A System.Windows.Controls.ListBox or related control such as System.Windows.Controls.ListBoxItem. + /// + ListBox, + + /// + /// A System.Windows.Controls.Menu or related control such as System.Windows.Controls.MenuItem. + /// + Menu, + + /// + /// A System.Windows.Controls.RadioButton or related control. + /// + RadioButton, + + /// + /// A System.Windows.Controls.ToolTip or related control. + /// + ToolTip, + + /// + /// A System.Windows.Documents.Hyperlink or related control. + /// + Hyperlink, + + /// + /// For panels that can contain text. + /// + TextFlow, + + /// + /// XML data. + /// + XmlData, + + /// + /// Font-related data such as font name, style, or size. + /// + Font, + + /// + /// Inherits its category from a parent node. + /// + Inherit, + + /// + /// Do not localize this resource. This does not apply to any child nodes that might exist. + /// + Ignore, + + /// + /// Do not localize this resource, or any child nodes whose category is set to Inherit. + /// + NeverLocalize, +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#SourceTrigger.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#SourceTrigger.g.verified.cs new file mode 100644 index 0000000..0f720ad --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Maui/_#SourceTrigger.g.verified.cs @@ -0,0 +1,34 @@ +//HintName: SourceTrigger.g.cs +#nullable enable + +namespace DependencyPropertyGenerator; + +/// +/// Describes the timing of binding source updates. +/// +internal enum SourceTrigger +{ + /// + /// The default System.Windows.Data.UpdateSourceTrigger value of the binding target + /// property. The default value for most dependency properties is + /// System.Windows.Data.UpdateSourceTrigger.PropertyChanged, + /// while the System.Windows.Controls.TextBox.Text property has a default value of + /// System.Windows.Data.UpdateSourceTrigger.LostFocus. + /// + Default = 0, + + /// + /// Updates the binding source immediately whenever the binding target property changes. + /// + PropertyChanged = 1, + + /// + /// Updates the binding source whenever the binding target element loses focus. + /// + LostFocus = 2, + + /// + /// Updates the binding source only when you call the System.Windows.Data.BindingExpression.UpdateSource method. + /// + Explicit = 3, +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/Tests.MultiTypesInOne_Diagnostics.verified.txt b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/Tests.MultiTypesInOne_Diagnostics.verified.txt new file mode 100644 index 0000000..ad47dbb --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/Tests.MultiTypesInOne_Diagnostics.verified.txt @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#DefaultBindingMode.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#DefaultBindingMode.g.verified.cs new file mode 100644 index 0000000..75f72c3 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#DefaultBindingMode.g.verified.cs @@ -0,0 +1,58 @@ +//HintName: DefaultBindingMode.g.cs +#nullable enable + +namespace DependencyPropertyGenerator; + +/// +/// Describes the direction of the data flow in a binding. +/// +internal enum DefaultBindingMode +{ + /// + /// Causes changes to either the source property or the target property to automatically + /// update the other. This type of binding is appropriate for editable forms or other + /// fully-interactive UI scenarios. + /// + TwoWay = 0, + + /// + /// Updates the binding target (target) property when the binding source (source) + /// changes. This type of binding is appropriate if the control being bound is implicitly + /// read-only. For instance, you may bind to a source such as a stock ticker. Or + /// perhaps your target property has no control interface provided for making changes, + /// such as a data-bound background color of a table. If there is no need to monitor + /// the changes of the target property, using the System.Windows.Data.BindingMode.OneWay + /// binding mode avoids the overhead of the System.Windows.Data.BindingMode.TwoWay + /// binding mode. + /// + OneWay = 1, + + /// + /// Updates the binding target when the application starts or when the data context + /// changes. This type of binding is appropriate if you are using data where either + /// a snapshot of the current state is appropriate to use or the data is truly static. + /// This type of binding is also useful if you want to initialize your target property + /// with some value from a source property and the data context is not known in advance. + /// This is essentially a simpler form of System.Windows.Data.BindingMode.OneWay + /// binding that provides better performance in cases where the source value does + /// not change. + /// + OneTime = 2, + + /// + /// Updates the source property when the target property changes. + /// + OneWayToSource = 3, + + /// + /// Uses the default System.Windows.Data.Binding.Mode value of the binding target. + /// The default value varies for each dependency property. In general, user-editable + /// control properties, such as those of text boxes and check boxes, default to two-way + /// bindings, whereas most other properties default to one-way bindings. A programmatic + /// way to determine whether a dependency property binds one-way or two-way by default + /// is to get the property metadata of the property using System.Windows.DependencyProperty.GetMetadata(System.Type) + /// and then check the Boolean value of the System.Windows.FrameworkPropertyMetadata.BindsTwoWayByDefault + /// property. + /// + Default = 4, +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#DependencyPropertyAttribute.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#DependencyPropertyAttribute.g.verified.cs new file mode 100644 index 0000000..efcf6e7 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#DependencyPropertyAttribute.g.verified.cs @@ -0,0 +1,480 @@ +//HintName: DependencyPropertyAttribute.g.cs +// ReSharper disable RedundantNameQualifier +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global +#nullable enable + +namespace DependencyPropertyGenerator; + +/// +/// Generates attached dependency property using DependencyProperty.Register. +/// +[global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = true)] +[global::System.Diagnostics.Conditional("DEPENDENCY_PROPERTY_GENERATOR_ATTRIBUTES")] +internal sealed class DependencyPropertyAttribute : global::System.Attribute +{ + /// + /// Name of this dependency property. + /// + public string Name { get; } + + /// + /// Type of this dependency property. + /// + public global::System.Type Type { get; } + + /// + /// Default value of this dependency property.
+ /// If you need to pass a new() expression, use .
+ /// Default - . + ///
+ public object? DefaultValue { get; set; } + + /// + /// Default value expression of this dependency property.
+ /// Used to pass a new() expression to an initializer.
+ /// Default - . + ///
+ public string? DefaultValueExpression { get; set; } + + /// + /// The property will create through RegisterReadOnly (if the platform supports it) and + /// the property setter will contain the protected modifier.
+ /// Default - . + ///
+ public bool IsReadOnly { get; set; } + + /// + /// Avalonia: Direct properties are a lightweight version of styled properties.
+ /// Default - . + ///
+ public bool IsDirect { get; set; } + + /// + /// Description of this dependency property.
+ /// The property will contain a with this value.
+ /// This will also be used in the xml documentation if not explicitly specified.
+ /// Default - . + ///
+ public string? Description { get; set; } + + /// + /// Category of this dependency property.
+ /// The property will contain a with this value.
+ /// Default - . + ///
+ public string? Category { get; set; } + + /// + /// Type converter of this dependency property.
+ /// The property will contain a with this value.
+ /// Default - . + ///
+ public global::System.Type? TypeConverter { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool Bindable { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool Browsable { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public global::System.ComponentModel.DesignerSerializationVisibility DesignerSerializationVisibility { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool ClsCompliant { get; set; } + + /// + /// The property will contain a System.Windows.LocalizabilityAttribute with this value.
+ /// Default - . + ///
+ public Localizability Localizability { get; set; } + + /// + /// The dependency property xml documentation.
+ /// Default - "<summary></summary>". + ///
+ public string XmlDocumentation { get; set; } = string.Empty; + + /// + /// The property getter/setter xml documentation.
+ /// Default - "<summary></summary>". + ///
+ public string PropertyXmlDocumentation { get; set; } = string.Empty; + + /// + /// For values other than default(type), will bind/rebind/remove the + /// On{Name}Changed_{EventName}(object sender, Args args) handler for the specified event.
+ /// It is recommended to specify as nameof(UIElement.Drop).
+ /// Default - string.Empty. + ///
+ public string BindEvent { get; set; } = string.Empty; + + /// + /// For values other than default(type), will bind/rebind/remove the + /// On{Name}Changed_{EventName}(object sender, Args args) handler for the specified event.
+ /// It is recommended to specify as nameof(UIElement.Drop).
+ /// Default - . + ///
+ public string[]? BindEvents { get; set; } + + /// + /// Allows to set a custom name for the OnChanged method call, allowing this method to be non-partial. + /// + public string OnChanged { get; set; } = string.Empty; + + /// + /// WPF: The measure pass of layout compositions is affected by value changes to this dependency property. + /// + public bool AffectsMeasure { get; set; } + + /// + /// WPF: The arrange pass of layout composition is affected by value changes to this dependency property. + /// + public bool AffectsArrange { get; set; } + + /// + /// WPF: The measure pass on the parent element is affected by value changes to this dependency property. + /// + public bool AffectsParentMeasure { get; set; } + + /// + /// WPF: The arrange pass on the parent element is affected by value changes to this dependency property. + /// + public bool AffectsParentArrange { get; set; } + + /// + /// WPF: Some aspect of rendering or layout composition (other than measure or arrange) is affected by value changes to this dependency property. + /// + public bool AffectsRender { get; set; } + + /// + /// WPF: The values of this dependency property are inherited by child elements. + /// + public bool Inherits { get; set; } + + /// + /// WPF: The values of this dependency property span separated trees for purposes of property value inheritance. + /// + public bool OverridesInheritanceBehavior { get; set; } + + /// + /// WPF: Data binding to this dependency property is not allowed. + /// + public bool NotDataBindable { get; set; } + + /// + /// WPF: The values of this dependency property should be saved or restored by journaling processes, or when navigating by Uniform resource identifiers (URIs). + /// + public bool Journal { get; set; } + + /// + /// WPF: The sub properties on the value of this dependency property do not affect any aspect of rendering. + /// + public bool SubPropertiesDoNotAffectRender { get; set; } + + /// + /// WPF: true to prevent the property system from animating the property that this metadata + /// is applied to. Such properties will raise a run-time exception originating from + /// the property system if animations of them are attempted. The default is false. + /// + public bool IsAnimationProhibited { get; set; } + + /// + /// WPF: The System.Windows.Data.UpdateSourceTrigger to use when bindings for this property + /// are applied that have their System.Windows.Data.UpdateSourceTrigger set to + /// System.Windows.Data.UpdateSourceTrigger.Default. + /// + public SourceTrigger DefaultUpdateSourceTrigger { get; set; } + + /// + /// Avalonia/MAUI: Default BindingMode.
+ /// WPF: Only Default/TwoWay is supported.
+ /// Default - . + ///
+ public DefaultBindingMode DefaultBindingMode { get; set; } = DefaultBindingMode.Default; + + /// + /// Avalonia-DirectProperty: Whether the property is interested in data validation.
+ /// Default - . + ///
+ public bool EnableDataValidation { get; set; } + + /// + /// WPF: partial method for coerceValueCallback will be created. + /// + public bool Coerce { get; set; } + + /// + /// WPF: partial method for validateValueCallback will be created.
+ /// Default - . + ///
+ public bool Validate { get; set; } + + /// + /// UWP/WinUI/Uno/MAUI: partial method for createDefaultValueCallback will be created. + /// + public bool CreateDefaultValueCallback { get; set; } + + /// + /// + /// + /// + /// + /// + public DependencyPropertyAttribute( + string name, + global::System.Type type) + { + Name = name ?? throw new global::System.ArgumentNullException(nameof(name)); + Type = type ?? throw new global::System.ArgumentNullException(nameof(type)); + } +} + +/// +/// Generates attached dependency property using DependencyProperty.Register. +/// +/// Type of this dependency property. +[global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = true)] +[global::System.Diagnostics.Conditional("DEPENDENCY_PROPERTY_GENERATOR_ATTRIBUTES")] +internal sealed class DependencyPropertyAttribute : global::System.Attribute +{ + /// + /// Name of this dependency property. + /// + public string Name { get; } + + /// + /// Type of this dependency property. + /// + public global::System.Type Type { get; } + + /// + /// Default value of this dependency property.
+ /// If you need to pass a new() expression, use .
+ /// Default - . + ///
+ public T? DefaultValue { get; set; } + + /// + /// Default value expression of this dependency property.
+ /// Used to pass a new() expression to an initializer.
+ /// Default - . + ///
+ public string? DefaultValueExpression { get; set; } + + /// + /// The property will create through RegisterReadOnly (if the platform supports it) and + /// the property setter will contain the protected modifier.
+ /// Default - . + ///
+ public bool IsReadOnly { get; set; } + + /// + /// Avalonia: Direct properties are a lightweight version of styled properties.
+ /// Default - . + ///
+ public bool IsDirect { get; set; } + + /// + /// Description of this dependency property.
+ /// The property will contain a with this value.
+ /// This will also be used in the xml documentation if not explicitly specified.
+ /// Default - . + ///
+ public string? Description { get; set; } + + /// + /// Category of this dependency property.
+ /// The property will contain a with this value.
+ /// Default - . + ///
+ public string? Category { get; set; } + + /// + /// Type converter of this dependency property.
+ /// The property will contain a with this value.
+ /// Default - . + ///
+ public global::System.Type? TypeConverter { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool Bindable { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool Browsable { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public global::System.ComponentModel.DesignerSerializationVisibility DesignerSerializationVisibility { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool ClsCompliant { get; set; } + + /// + /// The property will contain a System.Windows.LocalizabilityAttribute with this value.
+ /// Default - . + ///
+ public Localizability Localizability { get; set; } + + /// + /// The dependency property xml documentation.
+ /// Default - "<summary></summary>". + ///
+ public string XmlDocumentation { get; set; } = string.Empty; + + /// + /// The property getter/setter xml documentation.
+ /// Default - "<summary></summary>". + ///
+ public string PropertyXmlDocumentation { get; set; } = string.Empty; + + /// + /// For values other than default(type), will bind/rebind/remove the + /// On{Name}Changed_{EventName}(object sender, Args args) handler for the specified event.
+ /// It is recommended to specify as nameof(UIElement.Drop).
+ /// Default - string.Empty. + ///
+ public string BindEvent { get; set; } = string.Empty; + + /// + /// For values other than default(type), will bind/rebind/remove the + /// On{Name}Changed_{EventName}(object sender, Args args) handler for the specified event.
+ /// It is recommended to specify as nameof(UIElement.Drop).
+ /// Default - . + ///
+ public string[]? BindEvents { get; set; } + + /// + /// Allows to set a custom name for the OnChanged method call, allowing this method to be non-partial. + /// + public string OnChanged { get; set; } = string.Empty; + + /// + /// WPF: The measure pass of layout compositions is affected by value changes to this dependency property. + /// + public bool AffectsMeasure { get; set; } + + /// + /// WPF: The arrange pass of layout composition is affected by value changes to this dependency property. + /// + public bool AffectsArrange { get; set; } + + /// + /// WPF: The measure pass on the parent element is affected by value changes to this dependency property. + /// + public bool AffectsParentMeasure { get; set; } + + /// + /// WPF: The arrange pass on the parent element is affected by value changes to this dependency property. + /// + public bool AffectsParentArrange { get; set; } + + /// + /// WPF: Some aspect of rendering or layout composition (other than measure or arrange) is affected by value changes to this dependency property. + /// + public bool AffectsRender { get; set; } + + /// + /// WPF: The values of this dependency property are inherited by child elements. + /// + public bool Inherits { get; set; } + + /// + /// WPF: The values of this dependency property span separated trees for purposes of property value inheritance. + /// + public bool OverridesInheritanceBehavior { get; set; } + + /// + /// WPF: Data binding to this dependency property is not allowed. + /// + public bool NotDataBindable { get; set; } + + /// + /// WPF: The values of this dependency property should be saved or restored by journaling processes, or when navigating by Uniform resource identifiers (URIs). + /// + public bool Journal { get; set; } + + /// + /// WPF: The sub properties on the value of this dependency property do not affect any aspect of rendering. + /// + public bool SubPropertiesDoNotAffectRender { get; set; } + + /// + /// WPF: true to prevent the property system from animating the property that this metadata + /// is applied to. Such properties will raise a run-time exception originating from + /// the property system if animations of them are attempted. The default is false. + /// + public bool IsAnimationProhibited { get; set; } + + /// + /// WPF: The System.Windows.Data.UpdateSourceTrigger to use when bindings for this property + /// are applied that have their System.Windows.Data.UpdateSourceTrigger set to + /// System.Windows.Data.UpdateSourceTrigger.Default. + /// + public SourceTrigger DefaultUpdateSourceTrigger { get; set; } + + /// + /// Avalonia/MAUI: Default BindingMode.
+ /// WPF: Only Default/TwoWay is supported.
+ /// Default - . + ///
+ public DefaultBindingMode DefaultBindingMode { get; set; } = DefaultBindingMode.Default; + + /// + /// Avalonia-DirectProperty: Whether the property is interested in data validation.
+ /// Default - . + ///
+ public bool EnableDataValidation { get; set; } + + /// + /// WPF: partial method for coerceValueCallback will be created. + /// + public bool Coerce { get; set; } + + /// + /// WPF: partial method for validateValueCallback will be created.
+ /// Default - . + ///
+ public bool Validate { get; set; } + + /// + /// UWP/WinUI/Uno/MAUI: partial method for createDefaultValueCallback will be created. + /// + public bool CreateDefaultValueCallback { get; set; } + + /// + /// + /// + /// + /// + public DependencyPropertyAttribute( + string name) + { + Name = name ?? throw new global::System.ArgumentNullException(nameof(name)); + Type = typeof(T); + } +} diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty.g.verified.cs new file mode 100644 index 0000000..2846417 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty.g.verified.cs @@ -0,0 +1,44 @@ +//HintName: H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class AnotherControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Windows.UI.Xaml.DependencyProperty MyPropertyProperty = + global::Windows.UI.Xaml.DependencyProperty.Register( + name: "MyProperty", + propertyType: typeof(int), + ownerType: typeof(global::H.Generators.IntegrationTests.AnotherControl), + typeMetadata: new global::Windows.UI.Xaml.PropertyMetadata( + defaultValue: default(int), + propertyChangedCallback: static (sender, args) => + { + ((global::H.Generators.IntegrationTests.AnotherControl)sender).OnMyPropertyChanged(); + })); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty + { + get => (int)GetValue(MyPropertyProperty); + set => SetValue(MyPropertyProperty, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty2.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty2.g.verified.cs new file mode 100644 index 0000000..cd11da9 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty2.g.verified.cs @@ -0,0 +1,44 @@ +//HintName: H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty2.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class AnotherControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default((int, string)) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Windows.UI.Xaml.DependencyProperty MyProperty2Property = + global::Windows.UI.Xaml.DependencyProperty.Register( + name: "MyProperty2", + propertyType: typeof((int, string)), + ownerType: typeof(global::H.Generators.IntegrationTests.AnotherControl), + typeMetadata: new global::Windows.UI.Xaml.PropertyMetadata( + defaultValue: default((int, string)), + propertyChangedCallback: static (sender, args) => + { + ((global::H.Generators.IntegrationTests.AnotherControl)sender).OnMyProperty2Changed(); + })); + + /// + /// Default value: default((int, string)) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public (int, string) MyProperty2 + { + get => ((int, string))GetValue(MyProperty2Property); + set => SetValue(MyProperty2Property, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed((int, string) newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed((int, string) oldValue, (int, string) newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty3.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty3.g.verified.cs new file mode 100644 index 0000000..99e007b --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty3.g.verified.cs @@ -0,0 +1,44 @@ +//HintName: H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty3.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class AnotherControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Windows.UI.Xaml.DependencyProperty MyProperty3Property = + global::Windows.UI.Xaml.DependencyProperty.Register( + name: "MyProperty3", + propertyType: typeof(int), + ownerType: typeof(global::H.Generators.IntegrationTests.AnotherControl), + typeMetadata: new global::Windows.UI.Xaml.PropertyMetadata( + defaultValue: default(int), + propertyChangedCallback: static (sender, args) => + { + ((global::H.Generators.IntegrationTests.AnotherControl)sender).OnMyProperty3Changed(); + })); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty3 + { + get => (int)GetValue(MyProperty3Property); + set => SetValue(MyProperty3Property, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty.g.verified.cs new file mode 100644 index 0000000..b52af0b --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty.g.verified.cs @@ -0,0 +1,44 @@ +//HintName: H.Generators.IntegrationTests.MyControl.Properties.MyProperty.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class MyControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Windows.UI.Xaml.DependencyProperty MyPropertyProperty = + global::Windows.UI.Xaml.DependencyProperty.Register( + name: "MyProperty", + propertyType: typeof(int), + ownerType: typeof(global::H.Generators.IntegrationTests.MyControl), + typeMetadata: new global::Windows.UI.Xaml.PropertyMetadata( + defaultValue: default(int), + propertyChangedCallback: static (sender, args) => + { + ((global::H.Generators.IntegrationTests.MyControl)sender).OnMyPropertyChanged(); + })); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty + { + get => (int)GetValue(MyPropertyProperty); + set => SetValue(MyPropertyProperty, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty2.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty2.g.verified.cs new file mode 100644 index 0000000..25adb68 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty2.g.verified.cs @@ -0,0 +1,44 @@ +//HintName: H.Generators.IntegrationTests.MyControl.Properties.MyProperty2.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class MyControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Windows.UI.Xaml.DependencyProperty MyProperty2Property = + global::Windows.UI.Xaml.DependencyProperty.Register( + name: "MyProperty2", + propertyType: typeof(int), + ownerType: typeof(global::H.Generators.IntegrationTests.MyControl), + typeMetadata: new global::Windows.UI.Xaml.PropertyMetadata( + defaultValue: default(int), + propertyChangedCallback: static (sender, args) => + { + ((global::H.Generators.IntegrationTests.MyControl)sender).OnMyProperty2Changed(); + })); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty2 + { + get => (int)GetValue(MyProperty2Property); + set => SetValue(MyProperty2Property, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty3.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty3.g.verified.cs new file mode 100644 index 0000000..d2d23f0 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty3.g.verified.cs @@ -0,0 +1,44 @@ +//HintName: H.Generators.IntegrationTests.MyControl.Properties.MyProperty3.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class MyControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Windows.UI.Xaml.DependencyProperty MyProperty3Property = + global::Windows.UI.Xaml.DependencyProperty.Register( + name: "MyProperty3", + propertyType: typeof(int), + ownerType: typeof(global::H.Generators.IntegrationTests.MyControl), + typeMetadata: new global::Windows.UI.Xaml.PropertyMetadata( + defaultValue: default(int), + propertyChangedCallback: static (sender, args) => + { + ((global::H.Generators.IntegrationTests.MyControl)sender).OnMyProperty3Changed(); + })); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty3 + { + get => (int)GetValue(MyProperty3Property); + set => SetValue(MyProperty3Property, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#Localizability.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#Localizability.g.verified.cs new file mode 100644 index 0000000..e06ac0e --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#Localizability.g.verified.cs @@ -0,0 +1,101 @@ +//HintName: Localizability.g.cs +#nullable enable + +namespace DependencyPropertyGenerator; + +/// +/// Specifies the category value of a System.Windows.LocalizabilityAttribute +/// for a binary XAML (BAML) class or class member. +/// +internal enum Localizability +{ + /// + /// Resource does not belong to a standard category. + /// + None, + + /// + /// For a lengthy piece of text. + /// + Text, + + /// + /// For a single line of text, such as text used for a title. + /// + Title, + + /// + /// A System.Windows.Controls.Label or related control. + /// + Label, + + /// + /// A System.Windows.Controls.Button or related control. + /// + Button, + + /// + /// A System.Windows.Controls.CheckBox or related control. + /// + CheckBox, + + /// + /// A System.Windows.Controls.ComboBox or related control such as System.Windows.Controls.ComboBoxItem. + /// + ComboBox, + + /// + /// A System.Windows.Controls.ListBox or related control such as System.Windows.Controls.ListBoxItem. + /// + ListBox, + + /// + /// A System.Windows.Controls.Menu or related control such as System.Windows.Controls.MenuItem. + /// + Menu, + + /// + /// A System.Windows.Controls.RadioButton or related control. + /// + RadioButton, + + /// + /// A System.Windows.Controls.ToolTip or related control. + /// + ToolTip, + + /// + /// A System.Windows.Documents.Hyperlink or related control. + /// + Hyperlink, + + /// + /// For panels that can contain text. + /// + TextFlow, + + /// + /// XML data. + /// + XmlData, + + /// + /// Font-related data such as font name, style, or size. + /// + Font, + + /// + /// Inherits its category from a parent node. + /// + Inherit, + + /// + /// Do not localize this resource. This does not apply to any child nodes that might exist. + /// + Ignore, + + /// + /// Do not localize this resource, or any child nodes whose category is set to Inherit. + /// + NeverLocalize, +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#SourceTrigger.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#SourceTrigger.g.verified.cs new file mode 100644 index 0000000..0f720ad --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Uno/_#SourceTrigger.g.verified.cs @@ -0,0 +1,34 @@ +//HintName: SourceTrigger.g.cs +#nullable enable + +namespace DependencyPropertyGenerator; + +/// +/// Describes the timing of binding source updates. +/// +internal enum SourceTrigger +{ + /// + /// The default System.Windows.Data.UpdateSourceTrigger value of the binding target + /// property. The default value for most dependency properties is + /// System.Windows.Data.UpdateSourceTrigger.PropertyChanged, + /// while the System.Windows.Controls.TextBox.Text property has a default value of + /// System.Windows.Data.UpdateSourceTrigger.LostFocus. + /// + Default = 0, + + /// + /// Updates the binding source immediately whenever the binding target property changes. + /// + PropertyChanged = 1, + + /// + /// Updates the binding source whenever the binding target element loses focus. + /// + LostFocus = 2, + + /// + /// Updates the binding source only when you call the System.Windows.Data.BindingExpression.UpdateSource method. + /// + Explicit = 3, +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/Tests.MultiTypesInOne_Diagnostics.verified.txt b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/Tests.MultiTypesInOne_Diagnostics.verified.txt new file mode 100644 index 0000000..ad47dbb --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/Tests.MultiTypesInOne_Diagnostics.verified.txt @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#DefaultBindingMode.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#DefaultBindingMode.g.verified.cs new file mode 100644 index 0000000..75f72c3 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#DefaultBindingMode.g.verified.cs @@ -0,0 +1,58 @@ +//HintName: DefaultBindingMode.g.cs +#nullable enable + +namespace DependencyPropertyGenerator; + +/// +/// Describes the direction of the data flow in a binding. +/// +internal enum DefaultBindingMode +{ + /// + /// Causes changes to either the source property or the target property to automatically + /// update the other. This type of binding is appropriate for editable forms or other + /// fully-interactive UI scenarios. + /// + TwoWay = 0, + + /// + /// Updates the binding target (target) property when the binding source (source) + /// changes. This type of binding is appropriate if the control being bound is implicitly + /// read-only. For instance, you may bind to a source such as a stock ticker. Or + /// perhaps your target property has no control interface provided for making changes, + /// such as a data-bound background color of a table. If there is no need to monitor + /// the changes of the target property, using the System.Windows.Data.BindingMode.OneWay + /// binding mode avoids the overhead of the System.Windows.Data.BindingMode.TwoWay + /// binding mode. + /// + OneWay = 1, + + /// + /// Updates the binding target when the application starts or when the data context + /// changes. This type of binding is appropriate if you are using data where either + /// a snapshot of the current state is appropriate to use or the data is truly static. + /// This type of binding is also useful if you want to initialize your target property + /// with some value from a source property and the data context is not known in advance. + /// This is essentially a simpler form of System.Windows.Data.BindingMode.OneWay + /// binding that provides better performance in cases where the source value does + /// not change. + /// + OneTime = 2, + + /// + /// Updates the source property when the target property changes. + /// + OneWayToSource = 3, + + /// + /// Uses the default System.Windows.Data.Binding.Mode value of the binding target. + /// The default value varies for each dependency property. In general, user-editable + /// control properties, such as those of text boxes and check boxes, default to two-way + /// bindings, whereas most other properties default to one-way bindings. A programmatic + /// way to determine whether a dependency property binds one-way or two-way by default + /// is to get the property metadata of the property using System.Windows.DependencyProperty.GetMetadata(System.Type) + /// and then check the Boolean value of the System.Windows.FrameworkPropertyMetadata.BindsTwoWayByDefault + /// property. + /// + Default = 4, +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#DependencyPropertyAttribute.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#DependencyPropertyAttribute.g.verified.cs new file mode 100644 index 0000000..efcf6e7 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#DependencyPropertyAttribute.g.verified.cs @@ -0,0 +1,480 @@ +//HintName: DependencyPropertyAttribute.g.cs +// ReSharper disable RedundantNameQualifier +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global +#nullable enable + +namespace DependencyPropertyGenerator; + +/// +/// Generates attached dependency property using DependencyProperty.Register. +/// +[global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = true)] +[global::System.Diagnostics.Conditional("DEPENDENCY_PROPERTY_GENERATOR_ATTRIBUTES")] +internal sealed class DependencyPropertyAttribute : global::System.Attribute +{ + /// + /// Name of this dependency property. + /// + public string Name { get; } + + /// + /// Type of this dependency property. + /// + public global::System.Type Type { get; } + + /// + /// Default value of this dependency property.
+ /// If you need to pass a new() expression, use .
+ /// Default - . + ///
+ public object? DefaultValue { get; set; } + + /// + /// Default value expression of this dependency property.
+ /// Used to pass a new() expression to an initializer.
+ /// Default - . + ///
+ public string? DefaultValueExpression { get; set; } + + /// + /// The property will create through RegisterReadOnly (if the platform supports it) and + /// the property setter will contain the protected modifier.
+ /// Default - . + ///
+ public bool IsReadOnly { get; set; } + + /// + /// Avalonia: Direct properties are a lightweight version of styled properties.
+ /// Default - . + ///
+ public bool IsDirect { get; set; } + + /// + /// Description of this dependency property.
+ /// The property will contain a with this value.
+ /// This will also be used in the xml documentation if not explicitly specified.
+ /// Default - . + ///
+ public string? Description { get; set; } + + /// + /// Category of this dependency property.
+ /// The property will contain a with this value.
+ /// Default - . + ///
+ public string? Category { get; set; } + + /// + /// Type converter of this dependency property.
+ /// The property will contain a with this value.
+ /// Default - . + ///
+ public global::System.Type? TypeConverter { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool Bindable { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool Browsable { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public global::System.ComponentModel.DesignerSerializationVisibility DesignerSerializationVisibility { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool ClsCompliant { get; set; } + + /// + /// The property will contain a System.Windows.LocalizabilityAttribute with this value.
+ /// Default - . + ///
+ public Localizability Localizability { get; set; } + + /// + /// The dependency property xml documentation.
+ /// Default - "<summary></summary>". + ///
+ public string XmlDocumentation { get; set; } = string.Empty; + + /// + /// The property getter/setter xml documentation.
+ /// Default - "<summary></summary>". + ///
+ public string PropertyXmlDocumentation { get; set; } = string.Empty; + + /// + /// For values other than default(type), will bind/rebind/remove the + /// On{Name}Changed_{EventName}(object sender, Args args) handler for the specified event.
+ /// It is recommended to specify as nameof(UIElement.Drop).
+ /// Default - string.Empty. + ///
+ public string BindEvent { get; set; } = string.Empty; + + /// + /// For values other than default(type), will bind/rebind/remove the + /// On{Name}Changed_{EventName}(object sender, Args args) handler for the specified event.
+ /// It is recommended to specify as nameof(UIElement.Drop).
+ /// Default - . + ///
+ public string[]? BindEvents { get; set; } + + /// + /// Allows to set a custom name for the OnChanged method call, allowing this method to be non-partial. + /// + public string OnChanged { get; set; } = string.Empty; + + /// + /// WPF: The measure pass of layout compositions is affected by value changes to this dependency property. + /// + public bool AffectsMeasure { get; set; } + + /// + /// WPF: The arrange pass of layout composition is affected by value changes to this dependency property. + /// + public bool AffectsArrange { get; set; } + + /// + /// WPF: The measure pass on the parent element is affected by value changes to this dependency property. + /// + public bool AffectsParentMeasure { get; set; } + + /// + /// WPF: The arrange pass on the parent element is affected by value changes to this dependency property. + /// + public bool AffectsParentArrange { get; set; } + + /// + /// WPF: Some aspect of rendering or layout composition (other than measure or arrange) is affected by value changes to this dependency property. + /// + public bool AffectsRender { get; set; } + + /// + /// WPF: The values of this dependency property are inherited by child elements. + /// + public bool Inherits { get; set; } + + /// + /// WPF: The values of this dependency property span separated trees for purposes of property value inheritance. + /// + public bool OverridesInheritanceBehavior { get; set; } + + /// + /// WPF: Data binding to this dependency property is not allowed. + /// + public bool NotDataBindable { get; set; } + + /// + /// WPF: The values of this dependency property should be saved or restored by journaling processes, or when navigating by Uniform resource identifiers (URIs). + /// + public bool Journal { get; set; } + + /// + /// WPF: The sub properties on the value of this dependency property do not affect any aspect of rendering. + /// + public bool SubPropertiesDoNotAffectRender { get; set; } + + /// + /// WPF: true to prevent the property system from animating the property that this metadata + /// is applied to. Such properties will raise a run-time exception originating from + /// the property system if animations of them are attempted. The default is false. + /// + public bool IsAnimationProhibited { get; set; } + + /// + /// WPF: The System.Windows.Data.UpdateSourceTrigger to use when bindings for this property + /// are applied that have their System.Windows.Data.UpdateSourceTrigger set to + /// System.Windows.Data.UpdateSourceTrigger.Default. + /// + public SourceTrigger DefaultUpdateSourceTrigger { get; set; } + + /// + /// Avalonia/MAUI: Default BindingMode.
+ /// WPF: Only Default/TwoWay is supported.
+ /// Default - . + ///
+ public DefaultBindingMode DefaultBindingMode { get; set; } = DefaultBindingMode.Default; + + /// + /// Avalonia-DirectProperty: Whether the property is interested in data validation.
+ /// Default - . + ///
+ public bool EnableDataValidation { get; set; } + + /// + /// WPF: partial method for coerceValueCallback will be created. + /// + public bool Coerce { get; set; } + + /// + /// WPF: partial method for validateValueCallback will be created.
+ /// Default - . + ///
+ public bool Validate { get; set; } + + /// + /// UWP/WinUI/Uno/MAUI: partial method for createDefaultValueCallback will be created. + /// + public bool CreateDefaultValueCallback { get; set; } + + /// + /// + /// + /// + /// + /// + public DependencyPropertyAttribute( + string name, + global::System.Type type) + { + Name = name ?? throw new global::System.ArgumentNullException(nameof(name)); + Type = type ?? throw new global::System.ArgumentNullException(nameof(type)); + } +} + +/// +/// Generates attached dependency property using DependencyProperty.Register. +/// +/// Type of this dependency property. +[global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = true)] +[global::System.Diagnostics.Conditional("DEPENDENCY_PROPERTY_GENERATOR_ATTRIBUTES")] +internal sealed class DependencyPropertyAttribute : global::System.Attribute +{ + /// + /// Name of this dependency property. + /// + public string Name { get; } + + /// + /// Type of this dependency property. + /// + public global::System.Type Type { get; } + + /// + /// Default value of this dependency property.
+ /// If you need to pass a new() expression, use .
+ /// Default - . + ///
+ public T? DefaultValue { get; set; } + + /// + /// Default value expression of this dependency property.
+ /// Used to pass a new() expression to an initializer.
+ /// Default - . + ///
+ public string? DefaultValueExpression { get; set; } + + /// + /// The property will create through RegisterReadOnly (if the platform supports it) and + /// the property setter will contain the protected modifier.
+ /// Default - . + ///
+ public bool IsReadOnly { get; set; } + + /// + /// Avalonia: Direct properties are a lightweight version of styled properties.
+ /// Default - . + ///
+ public bool IsDirect { get; set; } + + /// + /// Description of this dependency property.
+ /// The property will contain a with this value.
+ /// This will also be used in the xml documentation if not explicitly specified.
+ /// Default - . + ///
+ public string? Description { get; set; } + + /// + /// Category of this dependency property.
+ /// The property will contain a with this value.
+ /// Default - . + ///
+ public string? Category { get; set; } + + /// + /// Type converter of this dependency property.
+ /// The property will contain a with this value.
+ /// Default - . + ///
+ public global::System.Type? TypeConverter { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool Bindable { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool Browsable { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public global::System.ComponentModel.DesignerSerializationVisibility DesignerSerializationVisibility { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool ClsCompliant { get; set; } + + /// + /// The property will contain a System.Windows.LocalizabilityAttribute with this value.
+ /// Default - . + ///
+ public Localizability Localizability { get; set; } + + /// + /// The dependency property xml documentation.
+ /// Default - "<summary></summary>". + ///
+ public string XmlDocumentation { get; set; } = string.Empty; + + /// + /// The property getter/setter xml documentation.
+ /// Default - "<summary></summary>". + ///
+ public string PropertyXmlDocumentation { get; set; } = string.Empty; + + /// + /// For values other than default(type), will bind/rebind/remove the + /// On{Name}Changed_{EventName}(object sender, Args args) handler for the specified event.
+ /// It is recommended to specify as nameof(UIElement.Drop).
+ /// Default - string.Empty. + ///
+ public string BindEvent { get; set; } = string.Empty; + + /// + /// For values other than default(type), will bind/rebind/remove the + /// On{Name}Changed_{EventName}(object sender, Args args) handler for the specified event.
+ /// It is recommended to specify as nameof(UIElement.Drop).
+ /// Default - . + ///
+ public string[]? BindEvents { get; set; } + + /// + /// Allows to set a custom name for the OnChanged method call, allowing this method to be non-partial. + /// + public string OnChanged { get; set; } = string.Empty; + + /// + /// WPF: The measure pass of layout compositions is affected by value changes to this dependency property. + /// + public bool AffectsMeasure { get; set; } + + /// + /// WPF: The arrange pass of layout composition is affected by value changes to this dependency property. + /// + public bool AffectsArrange { get; set; } + + /// + /// WPF: The measure pass on the parent element is affected by value changes to this dependency property. + /// + public bool AffectsParentMeasure { get; set; } + + /// + /// WPF: The arrange pass on the parent element is affected by value changes to this dependency property. + /// + public bool AffectsParentArrange { get; set; } + + /// + /// WPF: Some aspect of rendering or layout composition (other than measure or arrange) is affected by value changes to this dependency property. + /// + public bool AffectsRender { get; set; } + + /// + /// WPF: The values of this dependency property are inherited by child elements. + /// + public bool Inherits { get; set; } + + /// + /// WPF: The values of this dependency property span separated trees for purposes of property value inheritance. + /// + public bool OverridesInheritanceBehavior { get; set; } + + /// + /// WPF: Data binding to this dependency property is not allowed. + /// + public bool NotDataBindable { get; set; } + + /// + /// WPF: The values of this dependency property should be saved or restored by journaling processes, or when navigating by Uniform resource identifiers (URIs). + /// + public bool Journal { get; set; } + + /// + /// WPF: The sub properties on the value of this dependency property do not affect any aspect of rendering. + /// + public bool SubPropertiesDoNotAffectRender { get; set; } + + /// + /// WPF: true to prevent the property system from animating the property that this metadata + /// is applied to. Such properties will raise a run-time exception originating from + /// the property system if animations of them are attempted. The default is false. + /// + public bool IsAnimationProhibited { get; set; } + + /// + /// WPF: The System.Windows.Data.UpdateSourceTrigger to use when bindings for this property + /// are applied that have their System.Windows.Data.UpdateSourceTrigger set to + /// System.Windows.Data.UpdateSourceTrigger.Default. + /// + public SourceTrigger DefaultUpdateSourceTrigger { get; set; } + + /// + /// Avalonia/MAUI: Default BindingMode.
+ /// WPF: Only Default/TwoWay is supported.
+ /// Default - . + ///
+ public DefaultBindingMode DefaultBindingMode { get; set; } = DefaultBindingMode.Default; + + /// + /// Avalonia-DirectProperty: Whether the property is interested in data validation.
+ /// Default - . + ///
+ public bool EnableDataValidation { get; set; } + + /// + /// WPF: partial method for coerceValueCallback will be created. + /// + public bool Coerce { get; set; } + + /// + /// WPF: partial method for validateValueCallback will be created.
+ /// Default - . + ///
+ public bool Validate { get; set; } + + /// + /// UWP/WinUI/Uno/MAUI: partial method for createDefaultValueCallback will be created. + /// + public bool CreateDefaultValueCallback { get; set; } + + /// + /// + /// + /// + /// + public DependencyPropertyAttribute( + string name) + { + Name = name ?? throw new global::System.ArgumentNullException(nameof(name)); + Type = typeof(T); + } +} diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty.g.verified.cs new file mode 100644 index 0000000..c99115d --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty.g.verified.cs @@ -0,0 +1,44 @@ +//HintName: H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class AnotherControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Microsoft.UI.Xaml.DependencyProperty MyPropertyProperty = + global::Microsoft.UI.Xaml.DependencyProperty.Register( + name: "MyProperty", + propertyType: typeof(int), + ownerType: typeof(global::H.Generators.IntegrationTests.AnotherControl), + typeMetadata: new global::Microsoft.UI.Xaml.PropertyMetadata( + defaultValue: default(int), + propertyChangedCallback: static (sender, args) => + { + ((global::H.Generators.IntegrationTests.AnotherControl)sender).OnMyPropertyChanged(); + })); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty + { + get => (int)GetValue(MyPropertyProperty); + set => SetValue(MyPropertyProperty, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty2.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty2.g.verified.cs new file mode 100644 index 0000000..77a55c0 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty2.g.verified.cs @@ -0,0 +1,44 @@ +//HintName: H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty2.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class AnotherControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default((int, string)) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Microsoft.UI.Xaml.DependencyProperty MyProperty2Property = + global::Microsoft.UI.Xaml.DependencyProperty.Register( + name: "MyProperty2", + propertyType: typeof((int, string)), + ownerType: typeof(global::H.Generators.IntegrationTests.AnotherControl), + typeMetadata: new global::Microsoft.UI.Xaml.PropertyMetadata( + defaultValue: default((int, string)), + propertyChangedCallback: static (sender, args) => + { + ((global::H.Generators.IntegrationTests.AnotherControl)sender).OnMyProperty2Changed(); + })); + + /// + /// Default value: default((int, string)) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public (int, string) MyProperty2 + { + get => ((int, string))GetValue(MyProperty2Property); + set => SetValue(MyProperty2Property, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed((int, string) newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed((int, string) oldValue, (int, string) newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty3.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty3.g.verified.cs new file mode 100644 index 0000000..931d642 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty3.g.verified.cs @@ -0,0 +1,44 @@ +//HintName: H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty3.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class AnotherControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Microsoft.UI.Xaml.DependencyProperty MyProperty3Property = + global::Microsoft.UI.Xaml.DependencyProperty.Register( + name: "MyProperty3", + propertyType: typeof(int), + ownerType: typeof(global::H.Generators.IntegrationTests.AnotherControl), + typeMetadata: new global::Microsoft.UI.Xaml.PropertyMetadata( + defaultValue: default(int), + propertyChangedCallback: static (sender, args) => + { + ((global::H.Generators.IntegrationTests.AnotherControl)sender).OnMyProperty3Changed(); + })); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty3 + { + get => (int)GetValue(MyProperty3Property); + set => SetValue(MyProperty3Property, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty.g.verified.cs new file mode 100644 index 0000000..78a333d --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty.g.verified.cs @@ -0,0 +1,44 @@ +//HintName: H.Generators.IntegrationTests.MyControl.Properties.MyProperty.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class MyControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Microsoft.UI.Xaml.DependencyProperty MyPropertyProperty = + global::Microsoft.UI.Xaml.DependencyProperty.Register( + name: "MyProperty", + propertyType: typeof(int), + ownerType: typeof(global::H.Generators.IntegrationTests.MyControl), + typeMetadata: new global::Microsoft.UI.Xaml.PropertyMetadata( + defaultValue: default(int), + propertyChangedCallback: static (sender, args) => + { + ((global::H.Generators.IntegrationTests.MyControl)sender).OnMyPropertyChanged(); + })); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty + { + get => (int)GetValue(MyPropertyProperty); + set => SetValue(MyPropertyProperty, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty2.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty2.g.verified.cs new file mode 100644 index 0000000..966f092 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty2.g.verified.cs @@ -0,0 +1,44 @@ +//HintName: H.Generators.IntegrationTests.MyControl.Properties.MyProperty2.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class MyControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Microsoft.UI.Xaml.DependencyProperty MyProperty2Property = + global::Microsoft.UI.Xaml.DependencyProperty.Register( + name: "MyProperty2", + propertyType: typeof(int), + ownerType: typeof(global::H.Generators.IntegrationTests.MyControl), + typeMetadata: new global::Microsoft.UI.Xaml.PropertyMetadata( + defaultValue: default(int), + propertyChangedCallback: static (sender, args) => + { + ((global::H.Generators.IntegrationTests.MyControl)sender).OnMyProperty2Changed(); + })); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty2 + { + get => (int)GetValue(MyProperty2Property); + set => SetValue(MyProperty2Property, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty3.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty3.g.verified.cs new file mode 100644 index 0000000..e3cb849 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty3.g.verified.cs @@ -0,0 +1,44 @@ +//HintName: H.Generators.IntegrationTests.MyControl.Properties.MyProperty3.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class MyControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Microsoft.UI.Xaml.DependencyProperty MyProperty3Property = + global::Microsoft.UI.Xaml.DependencyProperty.Register( + name: "MyProperty3", + propertyType: typeof(int), + ownerType: typeof(global::H.Generators.IntegrationTests.MyControl), + typeMetadata: new global::Microsoft.UI.Xaml.PropertyMetadata( + defaultValue: default(int), + propertyChangedCallback: static (sender, args) => + { + ((global::H.Generators.IntegrationTests.MyControl)sender).OnMyProperty3Changed(); + })); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty3 + { + get => (int)GetValue(MyProperty3Property); + set => SetValue(MyProperty3Property, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#Localizability.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#Localizability.g.verified.cs new file mode 100644 index 0000000..e06ac0e --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#Localizability.g.verified.cs @@ -0,0 +1,101 @@ +//HintName: Localizability.g.cs +#nullable enable + +namespace DependencyPropertyGenerator; + +/// +/// Specifies the category value of a System.Windows.LocalizabilityAttribute +/// for a binary XAML (BAML) class or class member. +/// +internal enum Localizability +{ + /// + /// Resource does not belong to a standard category. + /// + None, + + /// + /// For a lengthy piece of text. + /// + Text, + + /// + /// For a single line of text, such as text used for a title. + /// + Title, + + /// + /// A System.Windows.Controls.Label or related control. + /// + Label, + + /// + /// A System.Windows.Controls.Button or related control. + /// + Button, + + /// + /// A System.Windows.Controls.CheckBox or related control. + /// + CheckBox, + + /// + /// A System.Windows.Controls.ComboBox or related control such as System.Windows.Controls.ComboBoxItem. + /// + ComboBox, + + /// + /// A System.Windows.Controls.ListBox or related control such as System.Windows.Controls.ListBoxItem. + /// + ListBox, + + /// + /// A System.Windows.Controls.Menu or related control such as System.Windows.Controls.MenuItem. + /// + Menu, + + /// + /// A System.Windows.Controls.RadioButton or related control. + /// + RadioButton, + + /// + /// A System.Windows.Controls.ToolTip or related control. + /// + ToolTip, + + /// + /// A System.Windows.Documents.Hyperlink or related control. + /// + Hyperlink, + + /// + /// For panels that can contain text. + /// + TextFlow, + + /// + /// XML data. + /// + XmlData, + + /// + /// Font-related data such as font name, style, or size. + /// + Font, + + /// + /// Inherits its category from a parent node. + /// + Inherit, + + /// + /// Do not localize this resource. This does not apply to any child nodes that might exist. + /// + Ignore, + + /// + /// Do not localize this resource, or any child nodes whose category is set to Inherit. + /// + NeverLocalize, +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#SourceTrigger.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#SourceTrigger.g.verified.cs new file mode 100644 index 0000000..0f720ad --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/UnoWinUi/_#SourceTrigger.g.verified.cs @@ -0,0 +1,34 @@ +//HintName: SourceTrigger.g.cs +#nullable enable + +namespace DependencyPropertyGenerator; + +/// +/// Describes the timing of binding source updates. +/// +internal enum SourceTrigger +{ + /// + /// The default System.Windows.Data.UpdateSourceTrigger value of the binding target + /// property. The default value for most dependency properties is + /// System.Windows.Data.UpdateSourceTrigger.PropertyChanged, + /// while the System.Windows.Controls.TextBox.Text property has a default value of + /// System.Windows.Data.UpdateSourceTrigger.LostFocus. + /// + Default = 0, + + /// + /// Updates the binding source immediately whenever the binding target property changes. + /// + PropertyChanged = 1, + + /// + /// Updates the binding source whenever the binding target element loses focus. + /// + LostFocus = 2, + + /// + /// Updates the binding source only when you call the System.Windows.Data.BindingExpression.UpdateSource method. + /// + Explicit = 3, +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/Tests.MultiTypesInOne_Diagnostics.verified.txt b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/Tests.MultiTypesInOne_Diagnostics.verified.txt new file mode 100644 index 0000000..ad47dbb --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/Tests.MultiTypesInOne_Diagnostics.verified.txt @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#DefaultBindingMode.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#DefaultBindingMode.g.verified.cs new file mode 100644 index 0000000..75f72c3 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#DefaultBindingMode.g.verified.cs @@ -0,0 +1,58 @@ +//HintName: DefaultBindingMode.g.cs +#nullable enable + +namespace DependencyPropertyGenerator; + +/// +/// Describes the direction of the data flow in a binding. +/// +internal enum DefaultBindingMode +{ + /// + /// Causes changes to either the source property or the target property to automatically + /// update the other. This type of binding is appropriate for editable forms or other + /// fully-interactive UI scenarios. + /// + TwoWay = 0, + + /// + /// Updates the binding target (target) property when the binding source (source) + /// changes. This type of binding is appropriate if the control being bound is implicitly + /// read-only. For instance, you may bind to a source such as a stock ticker. Or + /// perhaps your target property has no control interface provided for making changes, + /// such as a data-bound background color of a table. If there is no need to monitor + /// the changes of the target property, using the System.Windows.Data.BindingMode.OneWay + /// binding mode avoids the overhead of the System.Windows.Data.BindingMode.TwoWay + /// binding mode. + /// + OneWay = 1, + + /// + /// Updates the binding target when the application starts or when the data context + /// changes. This type of binding is appropriate if you are using data where either + /// a snapshot of the current state is appropriate to use or the data is truly static. + /// This type of binding is also useful if you want to initialize your target property + /// with some value from a source property and the data context is not known in advance. + /// This is essentially a simpler form of System.Windows.Data.BindingMode.OneWay + /// binding that provides better performance in cases where the source value does + /// not change. + /// + OneTime = 2, + + /// + /// Updates the source property when the target property changes. + /// + OneWayToSource = 3, + + /// + /// Uses the default System.Windows.Data.Binding.Mode value of the binding target. + /// The default value varies for each dependency property. In general, user-editable + /// control properties, such as those of text boxes and check boxes, default to two-way + /// bindings, whereas most other properties default to one-way bindings. A programmatic + /// way to determine whether a dependency property binds one-way or two-way by default + /// is to get the property metadata of the property using System.Windows.DependencyProperty.GetMetadata(System.Type) + /// and then check the Boolean value of the System.Windows.FrameworkPropertyMetadata.BindsTwoWayByDefault + /// property. + /// + Default = 4, +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#DependencyPropertyAttribute.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#DependencyPropertyAttribute.g.verified.cs new file mode 100644 index 0000000..efcf6e7 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#DependencyPropertyAttribute.g.verified.cs @@ -0,0 +1,480 @@ +//HintName: DependencyPropertyAttribute.g.cs +// ReSharper disable RedundantNameQualifier +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global +#nullable enable + +namespace DependencyPropertyGenerator; + +/// +/// Generates attached dependency property using DependencyProperty.Register. +/// +[global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = true)] +[global::System.Diagnostics.Conditional("DEPENDENCY_PROPERTY_GENERATOR_ATTRIBUTES")] +internal sealed class DependencyPropertyAttribute : global::System.Attribute +{ + /// + /// Name of this dependency property. + /// + public string Name { get; } + + /// + /// Type of this dependency property. + /// + public global::System.Type Type { get; } + + /// + /// Default value of this dependency property.
+ /// If you need to pass a new() expression, use .
+ /// Default - . + ///
+ public object? DefaultValue { get; set; } + + /// + /// Default value expression of this dependency property.
+ /// Used to pass a new() expression to an initializer.
+ /// Default - . + ///
+ public string? DefaultValueExpression { get; set; } + + /// + /// The property will create through RegisterReadOnly (if the platform supports it) and + /// the property setter will contain the protected modifier.
+ /// Default - . + ///
+ public bool IsReadOnly { get; set; } + + /// + /// Avalonia: Direct properties are a lightweight version of styled properties.
+ /// Default - . + ///
+ public bool IsDirect { get; set; } + + /// + /// Description of this dependency property.
+ /// The property will contain a with this value.
+ /// This will also be used in the xml documentation if not explicitly specified.
+ /// Default - . + ///
+ public string? Description { get; set; } + + /// + /// Category of this dependency property.
+ /// The property will contain a with this value.
+ /// Default - . + ///
+ public string? Category { get; set; } + + /// + /// Type converter of this dependency property.
+ /// The property will contain a with this value.
+ /// Default - . + ///
+ public global::System.Type? TypeConverter { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool Bindable { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool Browsable { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public global::System.ComponentModel.DesignerSerializationVisibility DesignerSerializationVisibility { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool ClsCompliant { get; set; } + + /// + /// The property will contain a System.Windows.LocalizabilityAttribute with this value.
+ /// Default - . + ///
+ public Localizability Localizability { get; set; } + + /// + /// The dependency property xml documentation.
+ /// Default - "<summary></summary>". + ///
+ public string XmlDocumentation { get; set; } = string.Empty; + + /// + /// The property getter/setter xml documentation.
+ /// Default - "<summary></summary>". + ///
+ public string PropertyXmlDocumentation { get; set; } = string.Empty; + + /// + /// For values other than default(type), will bind/rebind/remove the + /// On{Name}Changed_{EventName}(object sender, Args args) handler for the specified event.
+ /// It is recommended to specify as nameof(UIElement.Drop).
+ /// Default - string.Empty. + ///
+ public string BindEvent { get; set; } = string.Empty; + + /// + /// For values other than default(type), will bind/rebind/remove the + /// On{Name}Changed_{EventName}(object sender, Args args) handler for the specified event.
+ /// It is recommended to specify as nameof(UIElement.Drop).
+ /// Default - . + ///
+ public string[]? BindEvents { get; set; } + + /// + /// Allows to set a custom name for the OnChanged method call, allowing this method to be non-partial. + /// + public string OnChanged { get; set; } = string.Empty; + + /// + /// WPF: The measure pass of layout compositions is affected by value changes to this dependency property. + /// + public bool AffectsMeasure { get; set; } + + /// + /// WPF: The arrange pass of layout composition is affected by value changes to this dependency property. + /// + public bool AffectsArrange { get; set; } + + /// + /// WPF: The measure pass on the parent element is affected by value changes to this dependency property. + /// + public bool AffectsParentMeasure { get; set; } + + /// + /// WPF: The arrange pass on the parent element is affected by value changes to this dependency property. + /// + public bool AffectsParentArrange { get; set; } + + /// + /// WPF: Some aspect of rendering or layout composition (other than measure or arrange) is affected by value changes to this dependency property. + /// + public bool AffectsRender { get; set; } + + /// + /// WPF: The values of this dependency property are inherited by child elements. + /// + public bool Inherits { get; set; } + + /// + /// WPF: The values of this dependency property span separated trees for purposes of property value inheritance. + /// + public bool OverridesInheritanceBehavior { get; set; } + + /// + /// WPF: Data binding to this dependency property is not allowed. + /// + public bool NotDataBindable { get; set; } + + /// + /// WPF: The values of this dependency property should be saved or restored by journaling processes, or when navigating by Uniform resource identifiers (URIs). + /// + public bool Journal { get; set; } + + /// + /// WPF: The sub properties on the value of this dependency property do not affect any aspect of rendering. + /// + public bool SubPropertiesDoNotAffectRender { get; set; } + + /// + /// WPF: true to prevent the property system from animating the property that this metadata + /// is applied to. Such properties will raise a run-time exception originating from + /// the property system if animations of them are attempted. The default is false. + /// + public bool IsAnimationProhibited { get; set; } + + /// + /// WPF: The System.Windows.Data.UpdateSourceTrigger to use when bindings for this property + /// are applied that have their System.Windows.Data.UpdateSourceTrigger set to + /// System.Windows.Data.UpdateSourceTrigger.Default. + /// + public SourceTrigger DefaultUpdateSourceTrigger { get; set; } + + /// + /// Avalonia/MAUI: Default BindingMode.
+ /// WPF: Only Default/TwoWay is supported.
+ /// Default - . + ///
+ public DefaultBindingMode DefaultBindingMode { get; set; } = DefaultBindingMode.Default; + + /// + /// Avalonia-DirectProperty: Whether the property is interested in data validation.
+ /// Default - . + ///
+ public bool EnableDataValidation { get; set; } + + /// + /// WPF: partial method for coerceValueCallback will be created. + /// + public bool Coerce { get; set; } + + /// + /// WPF: partial method for validateValueCallback will be created.
+ /// Default - . + ///
+ public bool Validate { get; set; } + + /// + /// UWP/WinUI/Uno/MAUI: partial method for createDefaultValueCallback will be created. + /// + public bool CreateDefaultValueCallback { get; set; } + + /// + /// + /// + /// + /// + /// + public DependencyPropertyAttribute( + string name, + global::System.Type type) + { + Name = name ?? throw new global::System.ArgumentNullException(nameof(name)); + Type = type ?? throw new global::System.ArgumentNullException(nameof(type)); + } +} + +/// +/// Generates attached dependency property using DependencyProperty.Register. +/// +/// Type of this dependency property. +[global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = true)] +[global::System.Diagnostics.Conditional("DEPENDENCY_PROPERTY_GENERATOR_ATTRIBUTES")] +internal sealed class DependencyPropertyAttribute : global::System.Attribute +{ + /// + /// Name of this dependency property. + /// + public string Name { get; } + + /// + /// Type of this dependency property. + /// + public global::System.Type Type { get; } + + /// + /// Default value of this dependency property.
+ /// If you need to pass a new() expression, use .
+ /// Default - . + ///
+ public T? DefaultValue { get; set; } + + /// + /// Default value expression of this dependency property.
+ /// Used to pass a new() expression to an initializer.
+ /// Default - . + ///
+ public string? DefaultValueExpression { get; set; } + + /// + /// The property will create through RegisterReadOnly (if the platform supports it) and + /// the property setter will contain the protected modifier.
+ /// Default - . + ///
+ public bool IsReadOnly { get; set; } + + /// + /// Avalonia: Direct properties are a lightweight version of styled properties.
+ /// Default - . + ///
+ public bool IsDirect { get; set; } + + /// + /// Description of this dependency property.
+ /// The property will contain a with this value.
+ /// This will also be used in the xml documentation if not explicitly specified.
+ /// Default - . + ///
+ public string? Description { get; set; } + + /// + /// Category of this dependency property.
+ /// The property will contain a with this value.
+ /// Default - . + ///
+ public string? Category { get; set; } + + /// + /// Type converter of this dependency property.
+ /// The property will contain a with this value.
+ /// Default - . + ///
+ public global::System.Type? TypeConverter { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool Bindable { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool Browsable { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public global::System.ComponentModel.DesignerSerializationVisibility DesignerSerializationVisibility { get; set; } + + /// + /// The property will contain a with this value.
+ /// Default - . + ///
+ public bool ClsCompliant { get; set; } + + /// + /// The property will contain a System.Windows.LocalizabilityAttribute with this value.
+ /// Default - . + ///
+ public Localizability Localizability { get; set; } + + /// + /// The dependency property xml documentation.
+ /// Default - "<summary></summary>". + ///
+ public string XmlDocumentation { get; set; } = string.Empty; + + /// + /// The property getter/setter xml documentation.
+ /// Default - "<summary></summary>". + ///
+ public string PropertyXmlDocumentation { get; set; } = string.Empty; + + /// + /// For values other than default(type), will bind/rebind/remove the + /// On{Name}Changed_{EventName}(object sender, Args args) handler for the specified event.
+ /// It is recommended to specify as nameof(UIElement.Drop).
+ /// Default - string.Empty. + ///
+ public string BindEvent { get; set; } = string.Empty; + + /// + /// For values other than default(type), will bind/rebind/remove the + /// On{Name}Changed_{EventName}(object sender, Args args) handler for the specified event.
+ /// It is recommended to specify as nameof(UIElement.Drop).
+ /// Default - . + ///
+ public string[]? BindEvents { get; set; } + + /// + /// Allows to set a custom name for the OnChanged method call, allowing this method to be non-partial. + /// + public string OnChanged { get; set; } = string.Empty; + + /// + /// WPF: The measure pass of layout compositions is affected by value changes to this dependency property. + /// + public bool AffectsMeasure { get; set; } + + /// + /// WPF: The arrange pass of layout composition is affected by value changes to this dependency property. + /// + public bool AffectsArrange { get; set; } + + /// + /// WPF: The measure pass on the parent element is affected by value changes to this dependency property. + /// + public bool AffectsParentMeasure { get; set; } + + /// + /// WPF: The arrange pass on the parent element is affected by value changes to this dependency property. + /// + public bool AffectsParentArrange { get; set; } + + /// + /// WPF: Some aspect of rendering or layout composition (other than measure or arrange) is affected by value changes to this dependency property. + /// + public bool AffectsRender { get; set; } + + /// + /// WPF: The values of this dependency property are inherited by child elements. + /// + public bool Inherits { get; set; } + + /// + /// WPF: The values of this dependency property span separated trees for purposes of property value inheritance. + /// + public bool OverridesInheritanceBehavior { get; set; } + + /// + /// WPF: Data binding to this dependency property is not allowed. + /// + public bool NotDataBindable { get; set; } + + /// + /// WPF: The values of this dependency property should be saved or restored by journaling processes, or when navigating by Uniform resource identifiers (URIs). + /// + public bool Journal { get; set; } + + /// + /// WPF: The sub properties on the value of this dependency property do not affect any aspect of rendering. + /// + public bool SubPropertiesDoNotAffectRender { get; set; } + + /// + /// WPF: true to prevent the property system from animating the property that this metadata + /// is applied to. Such properties will raise a run-time exception originating from + /// the property system if animations of them are attempted. The default is false. + /// + public bool IsAnimationProhibited { get; set; } + + /// + /// WPF: The System.Windows.Data.UpdateSourceTrigger to use when bindings for this property + /// are applied that have their System.Windows.Data.UpdateSourceTrigger set to + /// System.Windows.Data.UpdateSourceTrigger.Default. + /// + public SourceTrigger DefaultUpdateSourceTrigger { get; set; } + + /// + /// Avalonia/MAUI: Default BindingMode.
+ /// WPF: Only Default/TwoWay is supported.
+ /// Default - . + ///
+ public DefaultBindingMode DefaultBindingMode { get; set; } = DefaultBindingMode.Default; + + /// + /// Avalonia-DirectProperty: Whether the property is interested in data validation.
+ /// Default - . + ///
+ public bool EnableDataValidation { get; set; } + + /// + /// WPF: partial method for coerceValueCallback will be created. + /// + public bool Coerce { get; set; } + + /// + /// WPF: partial method for validateValueCallback will be created.
+ /// Default - . + ///
+ public bool Validate { get; set; } + + /// + /// UWP/WinUI/Uno/MAUI: partial method for createDefaultValueCallback will be created. + /// + public bool CreateDefaultValueCallback { get; set; } + + /// + /// + /// + /// + /// + public DependencyPropertyAttribute( + string name) + { + Name = name ?? throw new global::System.ArgumentNullException(nameof(name)); + Type = typeof(T); + } +} diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty.g.verified.cs new file mode 100644 index 0000000..af15820 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty.g.verified.cs @@ -0,0 +1,48 @@ +//HintName: H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class AnotherControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::System.Windows.DependencyProperty MyPropertyProperty = + global::System.Windows.DependencyProperty.Register( + name: "MyProperty", + propertyType: typeof(int), + ownerType: typeof(global::H.Generators.IntegrationTests.AnotherControl), + typeMetadata: new global::System.Windows.FrameworkPropertyMetadata( + defaultValue: default(int), + flags: global::System.Windows.FrameworkPropertyMetadataOptions.None, + propertyChangedCallback: static (sender, args) => + { + ((global::H.Generators.IntegrationTests.AnotherControl)sender).OnMyPropertyChanged(); + }, + coerceValueCallback: null, + isAnimationProhibited: false), + validateValueCallback: null); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty + { + get => (int)GetValue(MyPropertyProperty); + set => SetValue(MyPropertyProperty, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty2.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty2.g.verified.cs new file mode 100644 index 0000000..7342f50 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty2.g.verified.cs @@ -0,0 +1,48 @@ +//HintName: H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty2.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class AnotherControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default((int, string)) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::System.Windows.DependencyProperty MyProperty2Property = + global::System.Windows.DependencyProperty.Register( + name: "MyProperty2", + propertyType: typeof((int, string)), + ownerType: typeof(global::H.Generators.IntegrationTests.AnotherControl), + typeMetadata: new global::System.Windows.FrameworkPropertyMetadata( + defaultValue: default((int, string)), + flags: global::System.Windows.FrameworkPropertyMetadataOptions.None, + propertyChangedCallback: static (sender, args) => + { + ((global::H.Generators.IntegrationTests.AnotherControl)sender).OnMyProperty2Changed(); + }, + coerceValueCallback: null, + isAnimationProhibited: false), + validateValueCallback: null); + + /// + /// Default value: default((int, string)) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public (int, string) MyProperty2 + { + get => ((int, string))GetValue(MyProperty2Property); + set => SetValue(MyProperty2Property, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed((int, string) newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed((int, string) oldValue, (int, string) newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty3.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty3.g.verified.cs new file mode 100644 index 0000000..740c7de --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty3.g.verified.cs @@ -0,0 +1,48 @@ +//HintName: H.Generators.IntegrationTests.AnotherControl.Properties.MyProperty3.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class AnotherControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::System.Windows.DependencyProperty MyProperty3Property = + global::System.Windows.DependencyProperty.Register( + name: "MyProperty3", + propertyType: typeof(int), + ownerType: typeof(global::H.Generators.IntegrationTests.AnotherControl), + typeMetadata: new global::System.Windows.FrameworkPropertyMetadata( + defaultValue: default(int), + flags: global::System.Windows.FrameworkPropertyMetadataOptions.None, + propertyChangedCallback: static (sender, args) => + { + ((global::H.Generators.IntegrationTests.AnotherControl)sender).OnMyProperty3Changed(); + }, + coerceValueCallback: null, + isAnimationProhibited: false), + validateValueCallback: null); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty3 + { + get => (int)GetValue(MyProperty3Property); + set => SetValue(MyProperty3Property, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty.g.verified.cs new file mode 100644 index 0000000..324eff7 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty.g.verified.cs @@ -0,0 +1,48 @@ +//HintName: H.Generators.IntegrationTests.MyControl.Properties.MyProperty.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class MyControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::System.Windows.DependencyProperty MyPropertyProperty = + global::System.Windows.DependencyProperty.Register( + name: "MyProperty", + propertyType: typeof(int), + ownerType: typeof(global::H.Generators.IntegrationTests.MyControl), + typeMetadata: new global::System.Windows.FrameworkPropertyMetadata( + defaultValue: default(int), + flags: global::System.Windows.FrameworkPropertyMetadataOptions.None, + propertyChangedCallback: static (sender, args) => + { + ((global::H.Generators.IntegrationTests.MyControl)sender).OnMyPropertyChanged(); + }, + coerceValueCallback: null, + isAnimationProhibited: false), + validateValueCallback: null); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty + { + get => (int)GetValue(MyPropertyProperty); + set => SetValue(MyPropertyProperty, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyPropertyChanged(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty2.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty2.g.verified.cs new file mode 100644 index 0000000..5d09a3f --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty2.g.verified.cs @@ -0,0 +1,48 @@ +//HintName: H.Generators.IntegrationTests.MyControl.Properties.MyProperty2.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class MyControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::System.Windows.DependencyProperty MyProperty2Property = + global::System.Windows.DependencyProperty.Register( + name: "MyProperty2", + propertyType: typeof(int), + ownerType: typeof(global::H.Generators.IntegrationTests.MyControl), + typeMetadata: new global::System.Windows.FrameworkPropertyMetadata( + defaultValue: default(int), + flags: global::System.Windows.FrameworkPropertyMetadataOptions.None, + propertyChangedCallback: static (sender, args) => + { + ((global::H.Generators.IntegrationTests.MyControl)sender).OnMyProperty2Changed(); + }, + coerceValueCallback: null, + isAnimationProhibited: false), + validateValueCallback: null); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty2 + { + get => (int)GetValue(MyProperty2Property); + set => SetValue(MyProperty2Property, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty2Changed(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty3.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty3.g.verified.cs new file mode 100644 index 0000000..f44a45e --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#H.Generators.IntegrationTests.MyControl.Properties.MyProperty3.g.verified.cs @@ -0,0 +1,48 @@ +//HintName: H.Generators.IntegrationTests.MyControl.Properties.MyProperty3.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class MyControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(int) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::System.Windows.DependencyProperty MyProperty3Property = + global::System.Windows.DependencyProperty.Register( + name: "MyProperty3", + propertyType: typeof(int), + ownerType: typeof(global::H.Generators.IntegrationTests.MyControl), + typeMetadata: new global::System.Windows.FrameworkPropertyMetadata( + defaultValue: default(int), + flags: global::System.Windows.FrameworkPropertyMetadataOptions.None, + propertyChangedCallback: static (sender, args) => + { + ((global::H.Generators.IntegrationTests.MyControl)sender).OnMyProperty3Changed(); + }, + coerceValueCallback: null, + isAnimationProhibited: false), + validateValueCallback: null); + + /// + /// Default value: default(int) + /// + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public int MyProperty3 + { + get => (int)GetValue(MyProperty3Property); + set => SetValue(MyProperty3Property, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(int newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnMyProperty3Changed(int oldValue, int newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#Localizability.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#Localizability.g.verified.cs new file mode 100644 index 0000000..e06ac0e --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#Localizability.g.verified.cs @@ -0,0 +1,101 @@ +//HintName: Localizability.g.cs +#nullable enable + +namespace DependencyPropertyGenerator; + +/// +/// Specifies the category value of a System.Windows.LocalizabilityAttribute +/// for a binary XAML (BAML) class or class member. +/// +internal enum Localizability +{ + /// + /// Resource does not belong to a standard category. + /// + None, + + /// + /// For a lengthy piece of text. + /// + Text, + + /// + /// For a single line of text, such as text used for a title. + /// + Title, + + /// + /// A System.Windows.Controls.Label or related control. + /// + Label, + + /// + /// A System.Windows.Controls.Button or related control. + /// + Button, + + /// + /// A System.Windows.Controls.CheckBox or related control. + /// + CheckBox, + + /// + /// A System.Windows.Controls.ComboBox or related control such as System.Windows.Controls.ComboBoxItem. + /// + ComboBox, + + /// + /// A System.Windows.Controls.ListBox or related control such as System.Windows.Controls.ListBoxItem. + /// + ListBox, + + /// + /// A System.Windows.Controls.Menu or related control such as System.Windows.Controls.MenuItem. + /// + Menu, + + /// + /// A System.Windows.Controls.RadioButton or related control. + /// + RadioButton, + + /// + /// A System.Windows.Controls.ToolTip or related control. + /// + ToolTip, + + /// + /// A System.Windows.Documents.Hyperlink or related control. + /// + Hyperlink, + + /// + /// For panels that can contain text. + /// + TextFlow, + + /// + /// XML data. + /// + XmlData, + + /// + /// Font-related data such as font name, style, or size. + /// + Font, + + /// + /// Inherits its category from a parent node. + /// + Inherit, + + /// + /// Do not localize this resource. This does not apply to any child nodes that might exist. + /// + Ignore, + + /// + /// Do not localize this resource, or any child nodes whose category is set to Inherit. + /// + NeverLocalize, +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#SourceTrigger.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#SourceTrigger.g.verified.cs new file mode 100644 index 0000000..0f720ad --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/MultiTypesInOne/Wpf/_#SourceTrigger.g.verified.cs @@ -0,0 +1,34 @@ +//HintName: SourceTrigger.g.cs +#nullable enable + +namespace DependencyPropertyGenerator; + +/// +/// Describes the timing of binding source updates. +/// +internal enum SourceTrigger +{ + /// + /// The default System.Windows.Data.UpdateSourceTrigger value of the binding target + /// property. The default value for most dependency properties is + /// System.Windows.Data.UpdateSourceTrigger.PropertyChanged, + /// while the System.Windows.Controls.TextBox.Text property has a default value of + /// System.Windows.Data.UpdateSourceTrigger.LostFocus. + /// + Default = 0, + + /// + /// Updates the binding source immediately whenever the binding target property changes. + /// + PropertyChanged = 1, + + /// + /// Updates the binding source whenever the binding target element loses focus. + /// + LostFocus = 2, + + /// + /// Updates the binding source only when you call the System.Windows.Data.BindingExpression.UpdateSource method. + /// + Explicit = 3, +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Tests.Properties.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Tests.Properties.cs index 0cc4fe9..5bfe2c1 100644 --- a/src/tests/DependencyPropertyGenerator.SnapshotTests/Tests.Properties.cs +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Tests.Properties.cs @@ -418,6 +418,50 @@ public Task Tuples(Framework framework) [DependencyProperty>(""TupleIntControl"")] public partial class MyControl : FrameworkElement { +}", framework); + } + + [DataTestMethod] + [DataRow(Framework.Wpf)] + [DataRow(Framework.Uno)] + [DataRow(Framework.UnoWinUi)] + [DataRow(Framework.Maui)] + [DataRow(Framework.Avalonia)] + public Task MultiTypesInOne(Framework framework) + { + return CheckSourceAsync(GetHeader(framework, string.Empty) + @" +[DependencyProperty(""MyProperty"")] +public partial class MyControl : FrameworkElement +{ + partial void OnMyPropertyChanged() + { + } +} +[DependencyProperty(""MyProperty2"")] +[DependencyProperty(""MyProperty3"", typeof(int))] +public partial class MyControl +{ + partial void OnMyProperty2Changed() + { + } + partial void OnMyProperty3Changed() + { + } +} +[DependencyProperty(""MyProperty"")] +[DependencyProperty<(int, string)>(""MyProperty2"")] +[DependencyProperty(""MyProperty3"", typeof(int))] +public partial class AnotherControl : FrameworkElement +{ + partial void OnMyPropertyChanged() + { + } + partial void OnMyProperty2Changed() + { + } + partial void OnMyProperty3Changed() + { + } }", framework); } } \ No newline at end of file