From 6e95414f4d35526f8727c8de904d5c305d1283a4 Mon Sep 17 00:00:00 2001 From: HavenDV Date: Thu, 4 Jan 2024 21:42:17 +0400 Subject: [PATCH] fix: Fixed issue with cref in description. --- .../Sources/Sources.Attributes.cs | 5 +- .../Sources/Sources.XmlDocumentation.cs | 3 +- ...scriptionWithCref_Diagnostics.verified.txt | 1 + .../_#DefaultBindingMode.g.verified.cs | 58 +++ ...#DependencyPropertyAttribute.g.verified.cs | 480 ++++++++++++++++++ ...ontrol.Properties.IsSpinning.g.verified.cs | 43 ++ .../Avalonia/_#Localizability.g.verified.cs | 101 ++++ .../Avalonia/_#SourceTrigger.g.verified.cs | 34 ++ ...scriptionWithCref_Diagnostics.verified.txt | 1 + .../Maui/_#DefaultBindingMode.g.verified.cs | 58 +++ ...#DependencyPropertyAttribute.g.verified.cs | 480 ++++++++++++++++++ ...MyGrid.Properties.IsSpinning.g.verified.cs | 53 ++ .../Maui/_#Localizability.g.verified.cs | 101 ++++ .../Maui/_#SourceTrigger.g.verified.cs | 34 ++ ...scriptionWithCref_Diagnostics.verified.txt | 1 + .../Uno/_#DefaultBindingMode.g.verified.cs | 58 +++ ...#DependencyPropertyAttribute.g.verified.cs | 480 ++++++++++++++++++ ...ontrol.Properties.IsSpinning.g.verified.cs | 43 ++ .../Uno/_#Localizability.g.verified.cs | 101 ++++ .../Uno/_#SourceTrigger.g.verified.cs | 34 ++ ...scriptionWithCref_Diagnostics.verified.txt | 1 + .../_#DefaultBindingMode.g.verified.cs | 58 +++ ...#DependencyPropertyAttribute.g.verified.cs | 480 ++++++++++++++++++ ...ontrol.Properties.IsSpinning.g.verified.cs | 43 ++ .../UnoWinUi/_#Localizability.g.verified.cs | 101 ++++ .../UnoWinUi/_#SourceTrigger.g.verified.cs | 34 ++ ...scriptionWithCref_Diagnostics.verified.txt | 1 + .../Wpf/_#DefaultBindingMode.g.verified.cs | 58 +++ ...#DependencyPropertyAttribute.g.verified.cs | 480 ++++++++++++++++++ ...ontrol.Properties.IsSpinning.g.verified.cs | 47 ++ .../Wpf/_#Localizability.g.verified.cs | 101 ++++ .../Wpf/_#SourceTrigger.g.verified.cs | 34 ++ .../Tests.Errors.cs | 16 + 33 files changed, 3620 insertions(+), 3 deletions(-) create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Avalonia/Tests.DescriptionWithCref_Diagnostics.verified.txt create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Avalonia/_#DefaultBindingMode.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Avalonia/_#DependencyPropertyAttribute.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Avalonia/_#H.Generators.IntegrationTests.MyControl.Properties.IsSpinning.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Avalonia/_#Localizability.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Avalonia/_#SourceTrigger.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Maui/Tests.DescriptionWithCref_Diagnostics.verified.txt create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Maui/_#DefaultBindingMode.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Maui/_#DependencyPropertyAttribute.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Maui/_#H.Generators.IntegrationTests.MyGrid.Properties.IsSpinning.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Maui/_#Localizability.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Maui/_#SourceTrigger.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Uno/Tests.DescriptionWithCref_Diagnostics.verified.txt create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Uno/_#DefaultBindingMode.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Uno/_#DependencyPropertyAttribute.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Uno/_#H.Generators.IntegrationTests.MyControl.Properties.IsSpinning.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Uno/_#Localizability.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Uno/_#SourceTrigger.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/UnoWinUi/Tests.DescriptionWithCref_Diagnostics.verified.txt create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/UnoWinUi/_#DefaultBindingMode.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/UnoWinUi/_#DependencyPropertyAttribute.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/UnoWinUi/_#H.Generators.IntegrationTests.MyControl.Properties.IsSpinning.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/UnoWinUi/_#Localizability.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/UnoWinUi/_#SourceTrigger.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Wpf/Tests.DescriptionWithCref_Diagnostics.verified.txt create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Wpf/_#DefaultBindingMode.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Wpf/_#DependencyPropertyAttribute.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Wpf/_#H.Generators.IntegrationTests.MyControl.Properties.IsSpinning.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Wpf/_#Localizability.g.verified.cs create mode 100644 src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Wpf/_#SourceTrigger.g.verified.cs diff --git a/src/libs/DependencyPropertyGenerator/Sources/Sources.Attributes.cs b/src/libs/DependencyPropertyGenerator/Sources/Sources.Attributes.cs index e7d337e..29c7d4e 100644 --- a/src/libs/DependencyPropertyGenerator/Sources/Sources.Attributes.cs +++ b/src/libs/DependencyPropertyGenerator/Sources/Sources.Attributes.cs @@ -1,4 +1,5 @@ using System.ComponentModel; +using System.Security; using H.Generators.Extensions; namespace H.Generators; @@ -51,8 +52,8 @@ private static string GenerateDescriptionAttribute(string? value) return GenerateComponentModelAttribute( nameof(DependencyPropertyData.Description), isMultilineString - ? $"@\"{value}\"" - : $"\"{value}\""); + ? $"@\"{SecurityElement.Escape(value)}\"" + : $"\"{SecurityElement.Escape(value)}\""); } private static string GenerateTypeConverterAttribute(string? value) diff --git a/src/libs/DependencyPropertyGenerator/Sources/Sources.XmlDocumentation.cs b/src/libs/DependencyPropertyGenerator/Sources/Sources.XmlDocumentation.cs index 125ac25..e5355b9 100644 --- a/src/libs/DependencyPropertyGenerator/Sources/Sources.XmlDocumentation.cs +++ b/src/libs/DependencyPropertyGenerator/Sources/Sources.XmlDocumentation.cs @@ -1,5 +1,6 @@ using H.Generators.Extensions; using System.Net; +using System.Security; namespace H.Generators; @@ -23,7 +24,7 @@ private static string GenerateXmlDocumentationFrom( ? property.Name : $""; var body = isProperty - ? property.Description != null ? $"{property.Description}
" : " " + ? property.Description != null ? $"{SecurityElement.Escape(property.Description)}
" : " " : $"Identifies the {name} dependency property.
"; value ??= @$" {body} diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Avalonia/Tests.DescriptionWithCref_Diagnostics.verified.txt b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Avalonia/Tests.DescriptionWithCref_Diagnostics.verified.txt new file mode 100644 index 0000000..ad47dbb --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Avalonia/Tests.DescriptionWithCref_Diagnostics.verified.txt @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Avalonia/_#DefaultBindingMode.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Avalonia/_#DefaultBindingMode.g.verified.cs new file mode 100644 index 0000000..75f72c3 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/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/DescriptionWithCref/Avalonia/_#DependencyPropertyAttribute.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Avalonia/_#DependencyPropertyAttribute.g.verified.cs new file mode 100644 index 0000000..efcf6e7 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/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/DescriptionWithCref/Avalonia/_#H.Generators.IntegrationTests.MyControl.Properties.IsSpinning.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Avalonia/_#H.Generators.IntegrationTests.MyControl.Properties.IsSpinning.g.verified.cs new file mode 100644 index 0000000..a3f73af --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Avalonia/_#H.Generators.IntegrationTests.MyControl.Properties.IsSpinning.g.verified.cs @@ -0,0 +1,43 @@ +//HintName: H.Generators.IntegrationTests.MyControl.Properties.IsSpinning.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class MyControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(bool) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Avalonia.StyledProperty IsSpinningProperty = + global::Avalonia.AvaloniaProperty.Register( + name: "IsSpinning", + defaultValue: default(bool), + inherits: false, + defaultBindingMode: global::Avalonia.Data.BindingMode.OneWay, + validate: null, + coerce: null); + + /// + /// <see cref="Style.TargetType"/> must be Label.
+ /// Default value: default(bool) + ///
+ [global::System.ComponentModel.Description("<see cref="Style.TargetType"/> must be Label.")] + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public bool IsSpinning + { + get => (bool)GetValue(IsSpinningProperty); + set => SetValue(IsSpinningProperty, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnIsSpinningChanged(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnIsSpinningChanged(bool newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnIsSpinningChanged(bool oldValue, bool newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Avalonia/_#Localizability.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Avalonia/_#Localizability.g.verified.cs new file mode 100644 index 0000000..e06ac0e --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/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/DescriptionWithCref/Avalonia/_#SourceTrigger.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Avalonia/_#SourceTrigger.g.verified.cs new file mode 100644 index 0000000..0f720ad --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/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/DescriptionWithCref/Maui/Tests.DescriptionWithCref_Diagnostics.verified.txt b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Maui/Tests.DescriptionWithCref_Diagnostics.verified.txt new file mode 100644 index 0000000..ad47dbb --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Maui/Tests.DescriptionWithCref_Diagnostics.verified.txt @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Maui/_#DefaultBindingMode.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Maui/_#DefaultBindingMode.g.verified.cs new file mode 100644 index 0000000..75f72c3 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/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/DescriptionWithCref/Maui/_#DependencyPropertyAttribute.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Maui/_#DependencyPropertyAttribute.g.verified.cs new file mode 100644 index 0000000..efcf6e7 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/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/DescriptionWithCref/Maui/_#H.Generators.IntegrationTests.MyGrid.Properties.IsSpinning.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Maui/_#H.Generators.IntegrationTests.MyGrid.Properties.IsSpinning.g.verified.cs new file mode 100644 index 0000000..2e95e32 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Maui/_#H.Generators.IntegrationTests.MyGrid.Properties.IsSpinning.g.verified.cs @@ -0,0 +1,53 @@ +//HintName: H.Generators.IntegrationTests.MyGrid.Properties.IsSpinning.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class MyGrid + { + /// + /// Identifies the dependency property.
+ /// Default value: default(bool) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Microsoft.Maui.Controls.BindableProperty IsSpinningProperty = + global::Microsoft.Maui.Controls.BindableProperty.Create( + propertyName: "IsSpinning", + returnType: typeof(bool), + declaringType: typeof(global::H.Generators.IntegrationTests.MyGrid), + defaultValue: default(bool), + defaultBindingMode: global::Microsoft.Maui.Controls.BindingMode.OneWay, + validateValue: null, + propertyChanged: null, + propertyChanging: null, + coerceValue: null, + defaultValueCreator: null); + + /// + /// <see cref="Style.TargetType"/> must be Label.
+ /// Default value: default(bool) + ///
+ [global::System.ComponentModel.Description("<see cref="Style.TargetType"/> must be Label.")] + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public bool IsSpinning + { + get => (bool)GetValue(IsSpinningProperty); + set => SetValue(IsSpinningProperty, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnIsSpinningChanged(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnIsSpinningChanged(bool newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnIsSpinningChanged(bool oldValue, bool newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnIsSpinningChanging(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnIsSpinningChanging(bool newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnIsSpinningChanging(bool oldValue, bool newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Maui/_#Localizability.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Maui/_#Localizability.g.verified.cs new file mode 100644 index 0000000..e06ac0e --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/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/DescriptionWithCref/Maui/_#SourceTrigger.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Maui/_#SourceTrigger.g.verified.cs new file mode 100644 index 0000000..0f720ad --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/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/DescriptionWithCref/Uno/Tests.DescriptionWithCref_Diagnostics.verified.txt b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Uno/Tests.DescriptionWithCref_Diagnostics.verified.txt new file mode 100644 index 0000000..ad47dbb --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Uno/Tests.DescriptionWithCref_Diagnostics.verified.txt @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Uno/_#DefaultBindingMode.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Uno/_#DefaultBindingMode.g.verified.cs new file mode 100644 index 0000000..75f72c3 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/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/DescriptionWithCref/Uno/_#DependencyPropertyAttribute.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Uno/_#DependencyPropertyAttribute.g.verified.cs new file mode 100644 index 0000000..efcf6e7 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/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/DescriptionWithCref/Uno/_#H.Generators.IntegrationTests.MyControl.Properties.IsSpinning.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Uno/_#H.Generators.IntegrationTests.MyControl.Properties.IsSpinning.g.verified.cs new file mode 100644 index 0000000..1e776ba --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Uno/_#H.Generators.IntegrationTests.MyControl.Properties.IsSpinning.g.verified.cs @@ -0,0 +1,43 @@ +//HintName: H.Generators.IntegrationTests.MyControl.Properties.IsSpinning.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class MyControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(bool) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Windows.UI.Xaml.DependencyProperty IsSpinningProperty = + global::Windows.UI.Xaml.DependencyProperty.Register( + name: "IsSpinning", + propertyType: typeof(bool), + ownerType: typeof(global::H.Generators.IntegrationTests.MyControl), + typeMetadata: new global::Windows.UI.Xaml.PropertyMetadata( + defaultValue: default(bool), + propertyChangedCallback: null)); + + /// + /// <see cref="Style.TargetType"/> must be Label.
+ /// Default value: default(bool) + ///
+ [global::System.ComponentModel.Description("<see cref="Style.TargetType"/> must be Label.")] + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public bool IsSpinning + { + get => (bool)GetValue(IsSpinningProperty); + set => SetValue(IsSpinningProperty, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnIsSpinningChanged(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnIsSpinningChanged(bool newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnIsSpinningChanged(bool oldValue, bool newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Uno/_#Localizability.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Uno/_#Localizability.g.verified.cs new file mode 100644 index 0000000..e06ac0e --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/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/DescriptionWithCref/Uno/_#SourceTrigger.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Uno/_#SourceTrigger.g.verified.cs new file mode 100644 index 0000000..0f720ad --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/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/DescriptionWithCref/UnoWinUi/Tests.DescriptionWithCref_Diagnostics.verified.txt b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/UnoWinUi/Tests.DescriptionWithCref_Diagnostics.verified.txt new file mode 100644 index 0000000..ad47dbb --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/UnoWinUi/Tests.DescriptionWithCref_Diagnostics.verified.txt @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/UnoWinUi/_#DefaultBindingMode.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/UnoWinUi/_#DefaultBindingMode.g.verified.cs new file mode 100644 index 0000000..75f72c3 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/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/DescriptionWithCref/UnoWinUi/_#DependencyPropertyAttribute.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/UnoWinUi/_#DependencyPropertyAttribute.g.verified.cs new file mode 100644 index 0000000..efcf6e7 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/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/DescriptionWithCref/UnoWinUi/_#H.Generators.IntegrationTests.MyControl.Properties.IsSpinning.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/UnoWinUi/_#H.Generators.IntegrationTests.MyControl.Properties.IsSpinning.g.verified.cs new file mode 100644 index 0000000..51c7db0 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/UnoWinUi/_#H.Generators.IntegrationTests.MyControl.Properties.IsSpinning.g.verified.cs @@ -0,0 +1,43 @@ +//HintName: H.Generators.IntegrationTests.MyControl.Properties.IsSpinning.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class MyControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(bool) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::Microsoft.UI.Xaml.DependencyProperty IsSpinningProperty = + global::Microsoft.UI.Xaml.DependencyProperty.Register( + name: "IsSpinning", + propertyType: typeof(bool), + ownerType: typeof(global::H.Generators.IntegrationTests.MyControl), + typeMetadata: new global::Microsoft.UI.Xaml.PropertyMetadata( + defaultValue: default(bool), + propertyChangedCallback: null)); + + /// + /// <see cref="Style.TargetType"/> must be Label.
+ /// Default value: default(bool) + ///
+ [global::System.ComponentModel.Description("<see cref="Style.TargetType"/> must be Label.")] + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public bool IsSpinning + { + get => (bool)GetValue(IsSpinningProperty); + set => SetValue(IsSpinningProperty, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnIsSpinningChanged(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnIsSpinningChanged(bool newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnIsSpinningChanged(bool oldValue, bool newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/UnoWinUi/_#Localizability.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/UnoWinUi/_#Localizability.g.verified.cs new file mode 100644 index 0000000..e06ac0e --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/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/DescriptionWithCref/UnoWinUi/_#SourceTrigger.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/UnoWinUi/_#SourceTrigger.g.verified.cs new file mode 100644 index 0000000..0f720ad --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/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/DescriptionWithCref/Wpf/Tests.DescriptionWithCref_Diagnostics.verified.txt b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Wpf/Tests.DescriptionWithCref_Diagnostics.verified.txt new file mode 100644 index 0000000..ad47dbb --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Wpf/Tests.DescriptionWithCref_Diagnostics.verified.txt @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Wpf/_#DefaultBindingMode.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Wpf/_#DefaultBindingMode.g.verified.cs new file mode 100644 index 0000000..75f72c3 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/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/DescriptionWithCref/Wpf/_#DependencyPropertyAttribute.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Wpf/_#DependencyPropertyAttribute.g.verified.cs new file mode 100644 index 0000000..efcf6e7 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/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/DescriptionWithCref/Wpf/_#H.Generators.IntegrationTests.MyControl.Properties.IsSpinning.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Wpf/_#H.Generators.IntegrationTests.MyControl.Properties.IsSpinning.g.verified.cs new file mode 100644 index 0000000..3756243 --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Wpf/_#H.Generators.IntegrationTests.MyControl.Properties.IsSpinning.g.verified.cs @@ -0,0 +1,47 @@ +//HintName: H.Generators.IntegrationTests.MyControl.Properties.IsSpinning.g.cs + +#nullable enable + +namespace H.Generators.IntegrationTests +{ + partial class MyControl + { + /// + /// Identifies the dependency property.
+ /// Default value: default(bool) + ///
+ [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + public static readonly global::System.Windows.DependencyProperty IsSpinningProperty = + global::System.Windows.DependencyProperty.Register( + name: "IsSpinning", + propertyType: typeof(bool), + ownerType: typeof(global::H.Generators.IntegrationTests.MyControl), + typeMetadata: new global::System.Windows.FrameworkPropertyMetadata( + defaultValue: default(bool), + flags: global::System.Windows.FrameworkPropertyMetadataOptions.None, + propertyChangedCallback: null, + coerceValueCallback: null, + isAnimationProhibited: false), + validateValueCallback: null); + + /// + /// <see cref="Style.TargetType"/> must be Label.
+ /// Default value: default(bool) + ///
+ [global::System.ComponentModel.Description("<see cref="Style.TargetType"/> must be Label.")] + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public bool IsSpinning + { + get => (bool)GetValue(IsSpinningProperty); + set => SetValue(IsSpinningProperty, value); + } + + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnIsSpinningChanged(); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnIsSpinningChanged(bool newValue); + [global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "0.0.0.0")] + partial void OnIsSpinningChanged(bool oldValue, bool newValue); + } +} \ No newline at end of file diff --git a/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Wpf/_#Localizability.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Wpf/_#Localizability.g.verified.cs new file mode 100644 index 0000000..e06ac0e --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/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/DescriptionWithCref/Wpf/_#SourceTrigger.g.verified.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/Wpf/_#SourceTrigger.g.verified.cs new file mode 100644 index 0000000..0f720ad --- /dev/null +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Snapshots/DescriptionWithCref/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.Errors.cs b/src/tests/DependencyPropertyGenerator.SnapshotTests/Tests.Errors.cs index 9e6c764..f1c784b 100644 --- a/src/tests/DependencyPropertyGenerator.SnapshotTests/Tests.Errors.cs +++ b/src/tests/DependencyPropertyGenerator.SnapshotTests/Tests.Errors.cs @@ -12,4 +12,20 @@ public partial class MyControl : UserControl { }", framework); } + + [DataTestMethod] + [DataRow(Framework.Wpf)] + [DataRow(Framework.Uno)] + [DataRow(Framework.UnoWinUi)] + [DataRow(Framework.Maui)] + [DataRow(Framework.Avalonia)] + public Task DescriptionWithCref(Framework framework) + { + return CheckSourceAsync(GetHeader(framework, "Controls") + @" +[DependencyProperty(""IsSpinning"", Description = "" must be Label."")] +public partial class MyControl : UserControl +{ +} +", framework); + } } \ No newline at end of file