Skip to content

Commit df07309

Browse files
authored
Merge pull request #247 from CommunityToolkit/dev/remove-attributes-conditional
Remove [Conditional] from MVVM Toolkit attributes
2 parents d1f7c05 + 414c837 commit df07309

14 files changed

+51
-157
lines changed

CommunityToolkit.Mvvm/ComponentModel/Attributes/AlsoBroadcastChangeAttribute.cs

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

55
using System;
6-
using System.Diagnostics;
76

87
namespace CommunityToolkit.Mvvm.ComponentModel;
98

@@ -36,7 +35,6 @@ namespace CommunityToolkit.Mvvm.ComponentModel;
3635
/// </code>
3736
/// </summary>
3837
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
39-
[Conditional("MVVMTOOLKIT_KEEP_SOURCE_GENERATOR_ATTRIBUTES")]
4038
public sealed class AlsoBroadcastChangeAttribute : Attribute
4139
{
4240
}

CommunityToolkit.Mvvm/ComponentModel/Attributes/AlsoNotifyCanExecuteForAttribute.cs

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

55
using System;
6-
using System.Diagnostics;
76
using System.Linq;
87
using CommunityToolkit.Mvvm.Input;
98

@@ -50,7 +49,6 @@ namespace CommunityToolkit.Mvvm.ComponentModel;
5049
/// </code>
5150
/// </summary>
5251
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true, Inherited = false)]
53-
[Conditional("MVVMTOOLKIT_KEEP_SOURCE_GENERATOR_ATTRIBUTES")]
5452
public sealed class AlsoNotifyCanExecuteForAttribute : Attribute
5553
{
5654
/// <summary>

CommunityToolkit.Mvvm/ComponentModel/Attributes/AlsoNotifyChangeForAttribute.cs

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

55
using System;
66
using System.ComponentModel;
7-
using System.Diagnostics;
87
using System.Linq;
98

109
namespace CommunityToolkit.Mvvm.ComponentModel;
@@ -69,7 +68,6 @@ namespace CommunityToolkit.Mvvm.ComponentModel;
6968
/// </code>
7069
/// </summary>
7170
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true, Inherited = false)]
72-
[Conditional("MVVMTOOLKIT_KEEP_SOURCE_GENERATOR_ATTRIBUTES")]
7371
public sealed class AlsoNotifyChangeForAttribute : Attribute
7472
{
7573
/// <summary>

CommunityToolkit.Mvvm/ComponentModel/Attributes/INotifyPropertyChangedAttribute.cs

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

55
using System;
66
using System.ComponentModel;
7-
using System.Diagnostics;
87

98
namespace CommunityToolkit.Mvvm.ComponentModel;
109

@@ -25,7 +24,6 @@ namespace CommunityToolkit.Mvvm.ComponentModel;
2524
/// </para>
2625
/// </summary>
2726
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
28-
[Conditional("MVVMTOOLKIT_KEEP_SOURCE_GENERATOR_ATTRIBUTES")]
2927
public sealed class INotifyPropertyChangedAttribute : Attribute
3028
{
3129
/// <summary>

CommunityToolkit.Mvvm/ComponentModel/Attributes/ObservableObjectAttribute.cs

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

55
using System;
66
using System.ComponentModel;
7-
using System.Diagnostics;
87

98
namespace CommunityToolkit.Mvvm.ComponentModel;
109

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

CommunityToolkit.Mvvm/ComponentModel/Attributes/ObservablePropertyAttribute.cs

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

55
using System;
66
using System.ComponentModel;
7-
using System.Diagnostics;
87

98
namespace CommunityToolkit.Mvvm.ComponentModel;
109

@@ -53,7 +52,6 @@ namespace CommunityToolkit.Mvvm.ComponentModel;
5352
/// source field name will be converted to uppercase (eg. <c>isEnabled</c> to <c>IsEnabled</c>).
5453
/// </remarks>
5554
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
56-
[Conditional("MVVMTOOLKIT_KEEP_SOURCE_GENERATOR_ATTRIBUTES")]
5755
public sealed class ObservablePropertyAttribute : Attribute
5856
{
5957
}

CommunityToolkit.Mvvm/ComponentModel/Attributes/ObservableRecipientAttribute.cs

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

55
using System;
6-
using System.Diagnostics;
76

87
namespace CommunityToolkit.Mvvm.ComponentModel;
98

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

CommunityToolkit.Mvvm/Input/Attributes/ICommandAttribute.cs

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

55
using System;
6-
using System.Diagnostics;
76
using System.Windows.Input;
87

98
namespace CommunityToolkit.Mvvm.Input;
@@ -65,7 +64,6 @@ namespace CommunityToolkit.Mvvm.Input;
6564
/// </para>
6665
/// </summary>
6766
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
68-
[Conditional("MVVMTOOLKIT_KEEP_SOURCE_GENERATOR_ATTRIBUTES")]
6967
public sealed class ICommandAttribute : Attribute
7068
{
7169
/// <summary>

dotnet Community Toolkit.sln

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Configuration", "Configurat
6363
EndProject
6464
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests", "tests\CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests\CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests.csproj", "{9E09DA49-4389-4ECE-8B68-EBDB1221DA90}"
6565
EndProject
66-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Mvvm.Internals.UnitTests", "tests\CommunityToolkit.Mvvm.Internals.UnitTests\CommunityToolkit.Mvvm.Internals.UnitTests.csproj", "{743D74BA-12AE-4639-AD77-B9DDA9C03255}"
67-
EndProject
68-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Mvvm.KeepSourceGeneratorAttributes.UnitTests", "tests\CommunityToolkit.Mvvm.KeepSourceGeneratorAttributes.UnitTests\CommunityToolkit.Mvvm.KeepSourceGeneratorAttributes.UnitTests.csproj", "{AFB55517-3B50-47E3-B9CA-F1C2770479B6}"
66+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Mvvm.Internals.UnitTests", "tests\CommunityToolkit.Mvvm.Internals.UnitTests\CommunityToolkit.Mvvm.Internals.UnitTests.csproj", "{743D74BA-12AE-4639-AD77-B9DDA9C03255}"
6967
EndProject
7068
Global
7169
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -341,26 +339,6 @@ Global
341339
{743D74BA-12AE-4639-AD77-B9DDA9C03255}.Release|x64.Build.0 = Release|Any CPU
342340
{743D74BA-12AE-4639-AD77-B9DDA9C03255}.Release|x86.ActiveCfg = Release|Any CPU
343341
{743D74BA-12AE-4639-AD77-B9DDA9C03255}.Release|x86.Build.0 = Release|Any CPU
344-
{AFB55517-3B50-47E3-B9CA-F1C2770479B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
345-
{AFB55517-3B50-47E3-B9CA-F1C2770479B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
346-
{AFB55517-3B50-47E3-B9CA-F1C2770479B6}.Debug|ARM.ActiveCfg = Debug|Any CPU
347-
{AFB55517-3B50-47E3-B9CA-F1C2770479B6}.Debug|ARM.Build.0 = Debug|Any CPU
348-
{AFB55517-3B50-47E3-B9CA-F1C2770479B6}.Debug|ARM64.ActiveCfg = Debug|Any CPU
349-
{AFB55517-3B50-47E3-B9CA-F1C2770479B6}.Debug|ARM64.Build.0 = Debug|Any CPU
350-
{AFB55517-3B50-47E3-B9CA-F1C2770479B6}.Debug|x64.ActiveCfg = Debug|Any CPU
351-
{AFB55517-3B50-47E3-B9CA-F1C2770479B6}.Debug|x64.Build.0 = Debug|Any CPU
352-
{AFB55517-3B50-47E3-B9CA-F1C2770479B6}.Debug|x86.ActiveCfg = Debug|Any CPU
353-
{AFB55517-3B50-47E3-B9CA-F1C2770479B6}.Debug|x86.Build.0 = Debug|Any CPU
354-
{AFB55517-3B50-47E3-B9CA-F1C2770479B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
355-
{AFB55517-3B50-47E3-B9CA-F1C2770479B6}.Release|Any CPU.Build.0 = Release|Any CPU
356-
{AFB55517-3B50-47E3-B9CA-F1C2770479B6}.Release|ARM.ActiveCfg = Release|Any CPU
357-
{AFB55517-3B50-47E3-B9CA-F1C2770479B6}.Release|ARM.Build.0 = Release|Any CPU
358-
{AFB55517-3B50-47E3-B9CA-F1C2770479B6}.Release|ARM64.ActiveCfg = Release|Any CPU
359-
{AFB55517-3B50-47E3-B9CA-F1C2770479B6}.Release|ARM64.Build.0 = Release|Any CPU
360-
{AFB55517-3B50-47E3-B9CA-F1C2770479B6}.Release|x64.ActiveCfg = Release|Any CPU
361-
{AFB55517-3B50-47E3-B9CA-F1C2770479B6}.Release|x64.Build.0 = Release|Any CPU
362-
{AFB55517-3B50-47E3-B9CA-F1C2770479B6}.Release|x86.ActiveCfg = Release|Any CPU
363-
{AFB55517-3B50-47E3-B9CA-F1C2770479B6}.Release|x86.Build.0 = Release|Any CPU
364342
EndGlobalSection
365343
GlobalSection(SolutionProperties) = preSolution
366344
HideSolutionNode = FALSE
@@ -377,7 +355,6 @@ Global
377355
{6640D447-C28D-4DBB-91F4-3ADCE0CA64AD} = {B30036C4-D514-4E5B-A323-587A061772CE}
378356
{9E09DA49-4389-4ECE-8B68-EBDB1221DA90} = {6640D447-C28D-4DBB-91F4-3ADCE0CA64AD}
379357
{743D74BA-12AE-4639-AD77-B9DDA9C03255} = {B30036C4-D514-4E5B-A323-587A061772CE}
380-
{AFB55517-3B50-47E3-B9CA-F1C2770479B6} = {6640D447-C28D-4DBB-91F4-3ADCE0CA64AD}
381358
EndGlobalSection
382359
GlobalSection(ExtensibilityGlobals) = postSolution
383360
SolutionGuid = {5403B0C4-F244-4F73-A35C-FE664D0F4345}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using CommunityToolkit.Mvvm.ComponentModel;
6+
7+
namespace CommunityToolkit.Mvvm.ExternalAssembly;
8+
9+
/// <summary>
10+
/// Test viewmodel for https://github.com/CommunityToolkit/dotnet/issues/222.
11+
/// </summary>
12+
[ObservableObject]
13+
public partial class ModelWithObservableObjectAttribute
14+
{
15+
[ObservableProperty]
16+
private string? _myProperty;
17+
}

0 commit comments

Comments
 (0)