Skip to content

Commit 866492b

Browse files
committed
Optimize registration for default values
1 parent 7f57e6c commit 866492b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

components/DependencyPropertyGenerator/CommunityToolkit.DependencyPropertyGenerator.SourceGenerators/DependencyPropertyGenerator.Execute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ static string GetExpressionWithTrailingSpace(Accessibility accessibility)
436436
string typeMetadata = propertyInfo switch
437437
{
438438
// Shared codegen
439-
{ DefaultValue: DependencyPropertyDefaultValue.Null, IsPropertyChangedCallbackImplemented: false, IsSharedPropertyChangedCallbackImplemented: false }
439+
{ DefaultValue: DependencyPropertyDefaultValue.Null or DependencyPropertyDefaultValue.Default, IsPropertyChangedCallbackImplemented: false, IsSharedPropertyChangedCallbackImplemented: false }
440440
=> "null",
441441
{ DefaultValue: DependencyPropertyDefaultValue.Callback(string methodName), IsPropertyChangedCallbackImplemented: false, IsSharedPropertyChangedCallbackImplemented: false }
442442
=> $"""

components/DependencyPropertyGenerator/CommunityToolkit.DependencyPropertyGenerator.Tests/Test_DependencyPropertyGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ partial class MyControl
4545
name: "Number",
4646
propertyType: typeof(int),
4747
ownerType: typeof(MyControl),
48-
typeMetadata: new global::Windows.UI.Xaml.PropertyMetadata(default(int)));
48+
typeMetadata: null);
4949
5050
/// <inheritdoc/>
5151
[global::System.CodeDom.Compiler.GeneratedCode("CommunityToolkit.WinUI.DependencyPropertyGenerator", <ASSEMBLY_VERSION>)]
@@ -464,7 +464,7 @@ partial class MyControl
464464
name: "Number",
465465
propertyType: typeof(int),
466466
ownerType: typeof(MyControl),
467-
typeMetadata: new global::Windows.UI.Xaml.PropertyMetadata(default(int)));
467+
typeMetadata: null);
468468
469469
/// <inheritdoc/>
470470
[global::System.CodeDom.Compiler.GeneratedCode("CommunityToolkit.WinUI.DependencyPropertyGenerator", <ASSEMBLY_VERSION>)]

0 commit comments

Comments
 (0)