diff --git a/dotnet.slnx b/dotnet.slnx
index 5d7e0583a..b1c170d4b 100644
--- a/dotnet.slnx
+++ b/dotnet.slnx
@@ -1,7 +1,4 @@
-
-
-
@@ -40,9 +37,11 @@
+
+
@@ -58,6 +57,7 @@
+
diff --git a/src/CommunityToolkit.Mvvm.SourceGenerators.Roslyn5000/CommunityToolkit.Mvvm.SourceGenerators.Roslyn5000.csproj b/src/CommunityToolkit.Mvvm.SourceGenerators.Roslyn5000/CommunityToolkit.Mvvm.SourceGenerators.Roslyn5000.csproj
new file mode 100644
index 000000000..de3752c63
--- /dev/null
+++ b/src/CommunityToolkit.Mvvm.SourceGenerators.Roslyn5000/CommunityToolkit.Mvvm.SourceGenerators.Roslyn5000.csproj
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/CommunityToolkit.Mvvm.SourceGenerators/CommunityToolkit.Mvvm.SourceGenerators.projitems b/src/CommunityToolkit.Mvvm.SourceGenerators/CommunityToolkit.Mvvm.SourceGenerators.projitems
index 9e719e412..c3294780f 100644
--- a/src/CommunityToolkit.Mvvm.SourceGenerators/CommunityToolkit.Mvvm.SourceGenerators.projitems
+++ b/src/CommunityToolkit.Mvvm.SourceGenerators/CommunityToolkit.Mvvm.SourceGenerators.projitems
@@ -57,7 +57,7 @@
-
+
diff --git a/src/CommunityToolkit.Mvvm.SourceGenerators/CommunityToolkit.Mvvm.SourceGenerators.props b/src/CommunityToolkit.Mvvm.SourceGenerators/CommunityToolkit.Mvvm.SourceGenerators.props
index 1517ae8cf..70ad36cf8 100644
--- a/src/CommunityToolkit.Mvvm.SourceGenerators/CommunityToolkit.Mvvm.SourceGenerators.props
+++ b/src/CommunityToolkit.Mvvm.SourceGenerators/CommunityToolkit.Mvvm.SourceGenerators.props
@@ -41,9 +41,13 @@
$(DefineConstants);ROSLYN_4_3_1_OR_GREATER
$(DefineConstants);ROSLYN_4_12_0_OR_GREATER
+ $(DefineConstants);ROSLYN_5_0_0_OR_GREATER
- $(NoWarn);RS2003
+ $(NoWarn);RS2003
+
+
+ 5.0.0-2.final
diff --git a/src/CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/ObservablePropertyGenerator.Execute.cs b/src/CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/ObservablePropertyGenerator.Execute.cs
index 17a97d5bd..2b2756ec4 100644
--- a/src/CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/ObservablePropertyGenerator.Execute.cs
+++ b/src/CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/ObservablePropertyGenerator.Execute.cs
@@ -80,11 +80,18 @@ public static bool IsCandidateValidForCompilation(MemberDeclarationSyntax node,
return false;
}
- // If the target is a property, we only support using C# preview.
- // This is because the generator is relying on the 'field' keyword.
- if (node is PropertyDeclarationSyntax && !semanticModel.Compilation.IsLanguageVersionPreview())
- {
+ // If the target is a property, we must either be using C# preview, or C# 14 or above. When we're using
+ // an older version of Roslyn, we know properties will never be supported anyway, so we have nothing to
+ // check. When we add Roslyn 18.0 support, we can also update this check to check for at least C# 14.
+ if (node is PropertyDeclarationSyntax)
+ {
+#if ROSLYN_5_0_0_OR_GREATER
+ return semanticModel.Compilation.HasLanguageVersionAtLeastEqualTo(LanguageVersion.CSharp14);
+#elif ROSLYN_4_12_0_OR_GREATER
+ return semanticModel.Compilation.IsLanguageVersionPreview();
+#else
return false;
+#endif
}
// All other cases are supported, the syntax filter is already validating that
diff --git a/src/CommunityToolkit.Mvvm.SourceGenerators/Diagnostics/Analyzers/RequiresCSharpLanguageVersionPreviewAnalyzer.cs b/src/CommunityToolkit.Mvvm.SourceGenerators/Diagnostics/Analyzers/RequiresCSharpLanguageVersion14OrPreviewAnalyzer.cs
similarity index 84%
rename from src/CommunityToolkit.Mvvm.SourceGenerators/Diagnostics/Analyzers/RequiresCSharpLanguageVersionPreviewAnalyzer.cs
rename to src/CommunityToolkit.Mvvm.SourceGenerators/Diagnostics/Analyzers/RequiresCSharpLanguageVersion14OrPreviewAnalyzer.cs
index 7cb7cd233..edfb39f23 100644
--- a/src/CommunityToolkit.Mvvm.SourceGenerators/Diagnostics/Analyzers/RequiresCSharpLanguageVersionPreviewAnalyzer.cs
+++ b/src/CommunityToolkit.Mvvm.SourceGenerators/Diagnostics/Analyzers/RequiresCSharpLanguageVersion14OrPreviewAnalyzer.cs
@@ -15,13 +15,13 @@
namespace CommunityToolkit.Mvvm.SourceGenerators;
///
-/// A diagnostic analyzer that generates errors when a property using [ObservableProperty] on a partial property is in a project with the C# language version not set to preview.
+/// A diagnostic analyzer that generates errors when a property using [ObservableProperty] on a partial property is in a project with the C# language version not set to 14.0 or 'preview'.
///
[DiagnosticAnalyzer(LanguageNames.CSharp)]
-public sealed class RequiresCSharpLanguageVersionPreviewAnalyzer : DiagnosticAnalyzer
+public sealed class RequiresCSharpLanguageVersion14OrPreviewAnalyzer : DiagnosticAnalyzer
{
///
- public override ImmutableArray SupportedDiagnostics { get; } = [CSharpLanguageVersionIsNotPreviewForObservableProperty];
+ public override ImmutableArray SupportedDiagnostics { get; } = [CSharpLanguageVersionIsNot14OrPreviewForObservableProperty];
///
public override void Initialize(AnalysisContext context)
@@ -31,8 +31,12 @@ public override void Initialize(AnalysisContext context)
context.RegisterCompilationStartAction(static context =>
{
- // If the language version is set to preview, we'll never emit diagnostics
+ // If the language version is set to preview or if we are set to at least C# 14.0, we'll never emit diagnostics
+#if ROSLYN_5_0_0_OR_GREATER
+ if (context.Compilation.HasLanguageVersionAtLeastEqualTo(LanguageVersion.CSharp14))
+#else
if (context.Compilation.IsLanguageVersionPreview())
+#endif
{
return;
}
@@ -69,7 +73,7 @@ public override void Initialize(AnalysisContext context)
if (context.Symbol.TryGetAttributeWithType(observablePropertySymbol, out AttributeData? observablePropertyAttribute))
{
context.ReportDiagnostic(Diagnostic.Create(
- CSharpLanguageVersionIsNotPreviewForObservableProperty,
+ CSharpLanguageVersionIsNot14OrPreviewForObservableProperty,
observablePropertyAttribute.GetLocation(),
context.Symbol));
}
diff --git a/src/CommunityToolkit.Mvvm.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs b/src/CommunityToolkit.Mvvm.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs
index b62fcb7ae..7c297892d 100644
--- a/src/CommunityToolkit.Mvvm.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs
+++ b/src/CommunityToolkit.Mvvm.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs
@@ -691,17 +691,17 @@ internal static class DiagnosticDescriptors
///
/// Gets a for the C# language version not being sufficient for [ObservableProperty] on partial properties.
///
- /// Format: "Using [ObservableProperty] on partial properties requires the C# language version to be set to 'preview', as support for the 'field' keyword is needed by the source generators to emit valid code (add preview to your .csproj/.props file)".
+ /// Format: "Using [ObservableProperty] on partial properties requires the C# language version to be set to at least 14.0 or 'preview', as support for the 'field' keyword is needed by the source generators to emit valid code (add 14.0 or preview to your .csproj/.props file)".
///
///
- public static readonly DiagnosticDescriptor CSharpLanguageVersionIsNotPreviewForObservableProperty = new DiagnosticDescriptor(
+ public static readonly DiagnosticDescriptor CSharpLanguageVersionIsNot14OrPreviewForObservableProperty = new DiagnosticDescriptor(
id: "MVVMTK0041",
- title: "C# language version is not 'preview'",
- messageFormat: """Using [ObservableProperty] on partial properties requires the C# language version to be set to 'preview', as support for the 'field' keyword is needed by the source generators to emit valid code (add preview to your .csproj/.props file)""",
+ title: "C# language version is not at least 14.0 or 'preview'",
+ messageFormat: """Using [ObservableProperty] on partial properties requires the C# language version to be set to at least 14.0 or 'preview', as support for the 'field' keyword is needed by the source generators to emit valid code (add 14.0 or preview to your .csproj/.props file)""",
category: typeof(ObservablePropertyGenerator).FullName,
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true,
- description: "The C# language version must be set to 'preview' when using [ObservableProperty] on partial properties for the source generators to emit valid code (the preview option must be set in the .csproj/.props file).",
+ description: "The C# language version must be set to at least 14.0 or 'preview' when using [ObservableProperty] on partial properties for the source generators to emit valid code (the 14.0 or preview option must be set in the .csproj/.props file).",
helpLinkUri: "https://aka.ms/mvvmtoolkit/errors/mvvmtk0041");
///
diff --git a/src/CommunityToolkit.Mvvm.SourceGenerators/Extensions/CompilationExtensions.cs b/src/CommunityToolkit.Mvvm.SourceGenerators/Extensions/CompilationExtensions.cs
index 6a584bbfb..98d24e846 100644
--- a/src/CommunityToolkit.Mvvm.SourceGenerators/Extensions/CompilationExtensions.cs
+++ b/src/CommunityToolkit.Mvvm.SourceGenerators/Extensions/CompilationExtensions.cs
@@ -27,6 +27,17 @@ public static bool HasLanguageVersionAtLeastEqualTo(this Compilation compilation
return ((CSharpCompilation)compilation).LanguageVersion >= languageVersion;
}
+ ///
+ /// Checks whether a given compilation (assumed to be for C#) is using a language version greater than a specified one.
+ ///
+ /// The to consider for analysis.
+ /// The minimum language version to check.
+ /// Whether is using a language version greater than the specified one.
+ public static bool HasLanguageVersionGreaterThan(this Compilation compilation, LanguageVersion languageVersion)
+ {
+ return ((CSharpCompilation)compilation).LanguageVersion > languageVersion;
+ }
+
///
/// Checks whether a given compilation (assumed to be for C#) is using the preview language version.
///
diff --git a/src/CommunityToolkit.Mvvm.SourceGenerators/Extensions/DiagnosticsExtensions.cs b/src/CommunityToolkit.Mvvm.SourceGenerators/Extensions/DiagnosticsExtensions.cs
index d6edd89f3..1f63dafb1 100644
--- a/src/CommunityToolkit.Mvvm.SourceGenerators/Extensions/DiagnosticsExtensions.cs
+++ b/src/CommunityToolkit.Mvvm.SourceGenerators/Extensions/DiagnosticsExtensions.cs
@@ -12,7 +12,7 @@
namespace CommunityToolkit.Mvvm.SourceGenerators.Extensions;
///
-/// Extension methods for , specifically for reporting diagnostics.
+/// Extension methods for working with diagnostics from incremental generator pipelines.
///
internal static class DiagnosticsExtensions
{
diff --git a/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj b/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj
index e3130dba5..b1a46c87f 100644
--- a/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj
+++ b/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj
@@ -69,6 +69,7 @@
+
@@ -123,9 +124,11 @@
+
+
\ No newline at end of file
diff --git a/tests/CommunityToolkit.Mvvm.Roslyn5000.UnitTests/CommunityToolkit.Mvvm.Roslyn5000.UnitTests.csproj b/tests/CommunityToolkit.Mvvm.Roslyn5000.UnitTests/CommunityToolkit.Mvvm.Roslyn5000.UnitTests.csproj
new file mode 100644
index 000000000..2d17602e9
--- /dev/null
+++ b/tests/CommunityToolkit.Mvvm.Roslyn5000.UnitTests/CommunityToolkit.Mvvm.Roslyn5000.UnitTests.csproj
@@ -0,0 +1,35 @@
+
+
+
+ net472;net8.0;net9.0
+ preview
+ true
+ $(DefineConstants);ROSLYN_4_12_0_OR_GREATER;ROSLYN_5_0_0_OR_GREATER
+
+
+ $(NoWarn);MVVMTK0042
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4120.UnitTests/Test_SourceGeneratorsCodegen.cs b/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4120.UnitTests/Test_SourceGeneratorsCodegen.cs
index 978017735..314f49e8c 100644
--- a/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4120.UnitTests/Test_SourceGeneratorsCodegen.cs
+++ b/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4120.UnitTests/Test_SourceGeneratorsCodegen.cs
@@ -91,6 +91,82 @@ partial int Number
VerifyGenerateSources(source, new[] { new ObservablePropertyGenerator() }, LanguageVersion.Preview, ("MyApp.MyViewModel.g.cs", result));
}
+#if ROSLYN_5_0_0_OR_GREATER
+ [TestMethod]
+ public void ObservablePropertyWithValueType_OnPartialProperty_WithNoModifiers_CSharp14_WorksCorrectly()
+ {
+ string source = """
+ using CommunityToolkit.Mvvm.ComponentModel;
+
+ namespace MyApp;
+
+ partial class MyViewModel : ObservableObject
+ {
+ [ObservableProperty]
+ partial int Number { get; set; }
+ }
+ """;
+
+ string result = """
+ //
+ #pragma warning disable
+ #nullable enable
+ namespace MyApp
+ {
+ ///
+ partial class MyViewModel
+ {
+ ///
+ [global::System.CodeDom.Compiler.GeneratedCode("CommunityToolkit.Mvvm.SourceGenerators.ObservablePropertyGenerator", )]
+ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ partial int Number
+ {
+ get => field;
+ set
+ {
+ if (!global::System.Collections.Generic.EqualityComparer.Default.Equals(field, value))
+ {
+ OnNumberChanging(value);
+ OnNumberChanging(default, value);
+ OnPropertyChanging(global::CommunityToolkit.Mvvm.ComponentModel.__Internals.__KnownINotifyPropertyChangingArgs.Number);
+ field = value;
+ OnNumberChanged(value);
+ OnNumberChanged(default, value);
+ OnPropertyChanged(global::CommunityToolkit.Mvvm.ComponentModel.__Internals.__KnownINotifyPropertyChangedArgs.Number);
+ }
+ }
+ }
+
+ /// Executes the logic for when is changing.
+ /// The new property value being set.
+ /// This method is invoked right before the value of is changed.
+ [global::System.CodeDom.Compiler.GeneratedCode("CommunityToolkit.Mvvm.SourceGenerators.ObservablePropertyGenerator", )]
+ partial void OnNumberChanging(int value);
+ /// Executes the logic for when is changing.
+ /// The previous property value that is being replaced.
+ /// The new property value being set.
+ /// This method is invoked right before the value of is changed.
+ [global::System.CodeDom.Compiler.GeneratedCode("CommunityToolkit.Mvvm.SourceGenerators.ObservablePropertyGenerator", )]
+ partial void OnNumberChanging(int oldValue, int newValue);
+ /// Executes the logic for when just changed.
+ /// The new property value that was set.
+ /// This method is invoked right after the value of is changed.
+ [global::System.CodeDom.Compiler.GeneratedCode("CommunityToolkit.Mvvm.SourceGenerators.ObservablePropertyGenerator", )]
+ partial void OnNumberChanged(int value);
+ /// Executes the logic for when just changed.
+ /// The previous property value that was replaced.
+ /// The new property value that was set.
+ /// This method is invoked right after the value of is changed.
+ [global::System.CodeDom.Compiler.GeneratedCode("CommunityToolkit.Mvvm.SourceGenerators.ObservablePropertyGenerator", )]
+ partial void OnNumberChanged(int oldValue, int newValue);
+ }
+ }
+ """;
+
+ VerifyGenerateSources(source, new[] { new ObservablePropertyGenerator() }, LanguageVersion.CSharp14, ("MyApp.MyViewModel.g.cs", result));
+ }
+#endif
+
// See https://github.com/CommunityToolkit/dotnet/issues/969
[TestMethod]
public void ObservablePropertyWithValueType_OnPartialProperty_RequiredProperty_WorksCorrectly()
diff --git a/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4120.UnitTests/Test_SourceGeneratorsDiagnostics.cs b/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4120.UnitTests/Test_SourceGeneratorsDiagnostics.cs
index e6845bbe5..28af166f7 100644
--- a/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4120.UnitTests/Test_SourceGeneratorsDiagnostics.cs
+++ b/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4120.UnitTests/Test_SourceGeneratorsDiagnostics.cs
@@ -22,13 +22,13 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [ObservableProperty]
+ [ObservableProperty]
public string Name { get; set; }
}
}
""";
- await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration(source, LanguageVersion.CSharp12);
+ await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration(source, LanguageVersion.CSharp12);
}
[TestMethod]
@@ -41,13 +41,13 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [{|MVVMTK0041:ObservableProperty|}]
+ [{|MVVMTK0041:ObservableProperty|}]
public partial string Name { get; set; }
}
}
""";
- await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(
+ await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(
source,
LanguageVersion.CSharp12,
@@ -67,13 +67,13 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [{|MVVMTK0041:ObservableProperty|}]
+ [{|MVVMTK0041:ObservableProperty|}]
public partial string Name { get; set; }
}
}
""";
- await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(
+ await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(
source,
LanguageVersion.CSharp13,
@@ -81,6 +81,32 @@ await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(
+ source,
+ LanguageVersion.Preview,
+
+ // /0/Test0.cs(8,31): error CS9248: Partial property 'SampleViewModel.Name' must have an implementation part.
+ DiagnosticResult.CompilerError("CS9248").WithSpan(8, 31, 8, 35).WithArguments("MyApp.SampleViewModel.Name"));
+ }
+#endif
+
[TestMethod]
public async Task RequireCSharpLanguageVersionPreviewAnalyzer_LanguageVersionIsPreview_DoesNotWarn()
{
@@ -91,13 +117,13 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [ObservableProperty]
+ [ObservableProperty]
public string Name { get; set; }
}
}
""";
- await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration(source, languageVersion: LanguageVersion.Preview);
+ await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration(source, languageVersion: LanguageVersion.Preview);
}
[TestMethod]
@@ -110,13 +136,13 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [ObservableProperty]
+ [ObservableProperty]
public partial string Name { get; set; }
}
}
""";
- await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(
+ await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(
source,
LanguageVersion.Preview,
@@ -134,7 +160,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [ObservableProperty]
+ [ObservableProperty]
private string name;
}
}
@@ -153,7 +179,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [ObservableProperty]
+ [ObservableProperty]
private string {|MVVMTK0042:name|};
}
}
@@ -172,7 +198,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [ObservableProperty]
+ [ObservableProperty]
public string Name { get; set; }
}
}
@@ -191,7 +217,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [ObservableProperty]
+ [ObservableProperty]
public partial string {|CS9248:Name|} { get; set; }
}
}
@@ -210,7 +236,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [ObservableProperty]
+ [ObservableProperty]
internal partial string {|CS9248:Name|} { get; private set; }
}
}
@@ -229,7 +255,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [ObservableProperty]
+ [ObservableProperty]
protected internal partial string {|CS9248:Name|} { get; private protected set; }
}
}
@@ -248,7 +274,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [{|MVVMTK0043:ObservableProperty|}]
+ [{|MVVMTK0043:ObservableProperty|}]
public string Name { get; set; }
}
}
@@ -267,7 +293,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [{|MVVMTK0043:ObservableProperty|}]
+ [{|MVVMTK0043:ObservableProperty|}]
public static partial string {|CS9248:Name|} { get; set; }
}
}
@@ -286,7 +312,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [{|MVVMTK0043:ObservableProperty|}]
+ [{|MVVMTK0043:ObservableProperty|}]
public partial string {|CS9248:Name|} { get; }
}
}
@@ -305,7 +331,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [{|MVVMTK0043:ObservableProperty|}]
+ [{|MVVMTK0043:ObservableProperty|}]
public partial string {|CS9248:Name|} { set; }
}
}
@@ -325,7 +351,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [{|MVVMTK0043:ObservableProperty|}]
+ [{|MVVMTK0043:ObservableProperty|}]
public partial string {|CS9248:Name|} { get; init; }
}
}
@@ -358,7 +384,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [ObservableProperty]
+ [ObservableProperty]
private static string name;
}
}
@@ -377,7 +403,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [ObservableProperty]
+ [ObservableProperty]
private static string name;
}
}
@@ -399,7 +425,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [ObservableProperty]
+ [ObservableProperty]
private string name;
}
}
@@ -421,7 +447,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [ObservableProperty]
+ [ObservableProperty]
private string name;
}
}
@@ -443,7 +469,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [ObservableProperty]
+ [ObservableProperty]
private string name;
}
}
@@ -465,7 +491,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [ObservableProperty]
+ [ObservableProperty]
private string {|MVVMTK0045:name|};
}
}
@@ -565,7 +591,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [ObservableProperty]
+ [ObservableProperty]
private string name;
}
}
@@ -587,7 +613,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [ObservableProperty]
+ [ObservableProperty]
private string {|MVVMTK0045:name|};
}
}
@@ -609,7 +635,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [ObservableProperty]
+ [ObservableProperty]
private string {|MVVMTK0045:name|};
}
}
@@ -631,7 +657,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [ObservableProperty]
+ [ObservableProperty]
private string {|MVVMTK0045:name|};
}
}
@@ -658,7 +684,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [ObservableProperty]
+ [ObservableProperty]
private string {|MVVMTK0045:name|};
}
}
@@ -1016,7 +1042,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [ObservableProperty]
+ [ObservableProperty]
public partial string {|CS9248:Name|} { get; set; }
}
}
@@ -1060,7 +1086,7 @@ namespace MyApp
{
public partial class SampleViewModel : ObservableObject
{
- [ObservableProperty]
+ [ObservableProperty]
public partial string Name { get; set; }
[GeneratedCode("CommunityToolkit.Mvvm.SourceGenerators.ObservablePropertyGenerator", "1.0.0")]
diff --git a/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn5000.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn5000.UnitTests.csproj b/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn5000.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn5000.UnitTests.csproj
new file mode 100644
index 000000000..7c3dd3749
--- /dev/null
+++ b/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn5000.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn5000.UnitTests.csproj
@@ -0,0 +1,35 @@
+
+
+
+ net472;net8.0;net9.0
+ $(DefineConstants);ROSLYN_4_3_1_OR_GREATER;ROSLYN_4_12_0_OR_GREATER;ROSLYN_5_0_0_OR_GREATER
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file