Skip to content

Commit f43c0e4

Browse files
committed
Update the embedded attribute type source file
1 parent 762665e commit f43c0e4

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

components/DependencyPropertyGenerator/CommunityToolkit.DependencyPropertyGenerator.SourceGenerators/EmbeddedResources/GeneratedDependencyPropertyAttribute.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace CommunityToolkit.WinUI
4747
internal sealed class GeneratedDependencyPropertyAttribute : global::System.Attribute
4848
{
4949
/// <summary>
50-
/// Gets a value indicating the default value to set for the property.
50+
/// Gets or sets a value indicating the default value to set for the property.
5151
/// </summary>
5252
/// <remarks>
5353
/// <para>
@@ -77,14 +77,33 @@ internal sealed class GeneratedDependencyPropertyAttribute : global::System.Attr
7777
public string? DefaultValueCallback { get; init; } = null!;
7878

7979
/// <summary>
80-
/// Gets a value indicating whether or not property values should be cached locally, to improve performance.
80+
/// Gets or sets a value indicating whether or not property values should be cached locally, to improve performance.
8181
/// This allows completely skipping boxing (for value types) and all WinRT marshalling when setting properties.
8282
/// </summary>
8383
/// <remarks>
8484
/// Local caching is disabled by default. It should be disabled in scenarios where the values of the dependency
8585
/// properties might also be set outside of the partial property implementation, meaning caching would be invalid.
8686
/// </remarks>
8787
public bool IsLocalCacheEnabled { get; init; } = false;
88+
89+
/// <summary>
90+
/// Gets or sets the type to use to register the property in metadata. The default value will exactly match the property type.
91+
/// </summary>
92+
/// <remarks>
93+
/// <para>
94+
/// This property allows customizing the property type in metadata, in advanced scenarios. For instance, it can be used to define
95+
/// properties of a <see cref="global::System.Nullable{T}"/> type (e.g. <see langword="bool?"/>) as just using <see cref="object"/> in metadata.
96+
/// This allows working around some issues primarily around classic (reflection-based) binding in XAML.
97+
/// </para>
98+
/// <para>
99+
/// This property should only be set when actually required (e.g. to ensure a specific scenario can work). The default behavior
100+
/// (i.e. the property type in metadata matching the declared property type) should work correctly in the vast majority of cases.
101+
/// </para>
102+
/// </remarks>
103+
#if NET8_0_OR_GREATER
104+
[global::System.Diagnostics.CodeAnalysis.DisallowNull]
105+
#endif
106+
public global::System.Type? PropertyType { get; init; } = null!;
88107
}
89108
}
90109

components/DependencyPropertyGenerator/src/GeneratedDependencyPropertyAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public sealed class GeneratedDependencyPropertyAttribute : Attribute
7171
public string? DefaultValueCallback { get; init; } = null!;
7272

7373
/// <summary>
74-
/// Gets a value indicating whether or not property values should be cached locally, to improve performance.
74+
/// Gets or sets a value indicating whether or not property values should be cached locally, to improve performance.
7575
/// This allows completely skipping boxing (for value types) and all WinRT marshalling when setting properties.
7676
/// </summary>
7777
/// <remarks>

0 commit comments

Comments
 (0)