Skip to content

Commit 350c237

Browse files
committed
Strip source generator attributes by default
Define "MVVMTOOLKIT_KEEP_SOURCE_GENERATOR_ATTRIBUTES" to keep them
1 parent f7a980e commit 350c237

File tree

7 files changed

+14
-0
lines changed

7 files changed

+14
-0
lines changed

CommunityToolkit.Mvvm/ComponentModel/Attributes/AlsoNotifyCanExecuteForAttribute.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System;
6+
using System.Diagnostics;
67
using System.Linq;
78
using CommunityToolkit.Mvvm.Input;
89

@@ -49,6 +50,7 @@ namespace CommunityToolkit.Mvvm.ComponentModel;
4950
/// </code>
5051
/// </summary>
5152
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true, Inherited = false)]
53+
[Conditional("MVVMTOOLKIT_KEEP_SOURCE_GENERATOR_ATTRIBUTES")]
5254
public sealed class AlsoNotifyCanExecuteForAttribute : Attribute
5355
{
5456
/// <summary>

CommunityToolkit.Mvvm/ComponentModel/Attributes/AlsoNotifyChangeForAttribute.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using System;
66
using System.ComponentModel;
7+
using System.Diagnostics;
78
using System.Linq;
89

910
namespace CommunityToolkit.Mvvm.ComponentModel;
@@ -68,6 +69,7 @@ namespace CommunityToolkit.Mvvm.ComponentModel;
6869
/// </code>
6970
/// </summary>
7071
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true, Inherited = false)]
72+
[Conditional("MVVMTOOLKIT_KEEP_SOURCE_GENERATOR_ATTRIBUTES")]
7173
public sealed class AlsoNotifyChangeForAttribute : Attribute
7274
{
7375
/// <summary>

CommunityToolkit.Mvvm/ComponentModel/Attributes/INotifyPropertyChangedAttribute.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using System;
66
using System.ComponentModel;
7+
using System.Diagnostics;
78

89
namespace CommunityToolkit.Mvvm.ComponentModel;
910

@@ -24,6 +25,7 @@ namespace CommunityToolkit.Mvvm.ComponentModel;
2425
/// </para>
2526
/// </summary>
2627
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
28+
[Conditional("MVVMTOOLKIT_KEEP_SOURCE_GENERATOR_ATTRIBUTES")]
2729
public sealed class INotifyPropertyChangedAttribute : Attribute
2830
{
2931
/// <summary>

CommunityToolkit.Mvvm/ComponentModel/Attributes/ObservableObjectAttribute.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using System;
66
using System.ComponentModel;
7+
using System.Diagnostics;
78

89
namespace CommunityToolkit.Mvvm.ComponentModel;
910

@@ -26,6 +27,7 @@ namespace CommunityToolkit.Mvvm.ComponentModel;
2627
/// And with this, the same APIs from <see cref="ObservableObject"/> will be available on this type as well.
2728
/// </summary>
2829
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
30+
[Conditional("MVVMTOOLKIT_KEEP_SOURCE_GENERATOR_ATTRIBUTES")]
2931
public sealed class ObservableObjectAttribute : Attribute
3032
{
3133
}

CommunityToolkit.Mvvm/ComponentModel/Attributes/ObservablePropertyAttribute.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using System;
66
using System.ComponentModel;
7+
using System.Diagnostics;
78

89
namespace CommunityToolkit.Mvvm.ComponentModel;
910

@@ -51,6 +52,7 @@ namespace CommunityToolkit.Mvvm.ComponentModel;
5152
/// source field name will be converted to uppercase (eg. <c>isEnabled</c> to <c>IsEnabled</c>).
5253
/// </remarks>
5354
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
55+
[Conditional("MVVMTOOLKIT_KEEP_SOURCE_GENERATOR_ATTRIBUTES")]
5456
public sealed class ObservablePropertyAttribute : Attribute
5557
{
5658
}

CommunityToolkit.Mvvm/ComponentModel/Attributes/ObservableRecipientAttribute.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System;
6+
using System.Diagnostics;
67

78
namespace CommunityToolkit.Mvvm.ComponentModel;
89

@@ -40,6 +41,7 @@ namespace CommunityToolkit.Mvvm.ComponentModel;
4041
/// If this condition is not met, the code will fail to build.
4142
/// </remarks>
4243
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
44+
[Conditional("MVVMTOOLKIT_KEEP_SOURCE_GENERATOR_ATTRIBUTES")]
4345
public sealed class ObservableRecipientAttribute : Attribute
4446
{
4547
}

CommunityToolkit.Mvvm/Input/Attributes/ICommandAttribute.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System;
6+
using System.Diagnostics;
67
using System.Windows.Input;
78

89
namespace CommunityToolkit.Mvvm.Input;
@@ -60,6 +61,7 @@ namespace CommunityToolkit.Mvvm.Input;
6061
/// </para>
6162
/// </summary>
6263
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
64+
[Conditional("MVVMTOOLKIT_KEEP_SOURCE_GENERATOR_ATTRIBUTES")]
6365
public sealed class ICommandAttribute : Attribute
6466
{
6567
/// <summary>

0 commit comments

Comments
 (0)