Skip to content

Commit 3d7b45c

Browse files
authored
Merge pull request #121 from CommunityToolkit/dev/fix-build-warnings
Fix analyzer build warnings/errors
2 parents 0813779 + bc6f26f commit 3d7b45c

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

CommunityToolkit.Mvvm.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
using Microsoft.CodeAnalysis;
77
using Microsoft.CodeAnalysis.CSharp;
88

9+
#pragma warning disable IDE0090 // Use 'new DiagnosticDescriptor(...)'
10+
911
namespace CommunityToolkit.Mvvm.SourceGenerators.Diagnostics;
1012

1113
/// <summary>
@@ -19,7 +21,7 @@ internal static class DiagnosticDescriptors
1921
/// Format: <c>"Cannot apply [INotifyPropertyChangedAttribute] to type {0}, as it already declares the INotifyPropertyChanged interface"</c>.
2022
/// </para>
2123
/// </summary>
22-
public static readonly DiagnosticDescriptor DuplicateINotifyPropertyChangedInterfaceForINotifyPropertyChangedAttributeError = new(
24+
public static readonly DiagnosticDescriptor DuplicateINotifyPropertyChangedInterfaceForINotifyPropertyChangedAttributeError = new DiagnosticDescriptor(
2325
id: "MVVMTK0001",
2426
title: $"Duplicate {nameof(INotifyPropertyChanged)} definition",
2527
messageFormat: $"Cannot apply [INotifyPropertyChanged] to type {{0}}, as it already declares the {nameof(INotifyPropertyChanged)} interface",
@@ -35,7 +37,7 @@ internal static class DiagnosticDescriptors
3537
/// Format: <c>"Cannot apply [ObservableObjectAttribute] to type {0}, as it already declares the INotifyPropertyChanged interface"</c>.
3638
/// </para>
3739
/// </summary>
38-
public static readonly DiagnosticDescriptor DuplicateINotifyPropertyChangedInterfaceForObservableObjectAttributeError = new(
40+
public static readonly DiagnosticDescriptor DuplicateINotifyPropertyChangedInterfaceForObservableObjectAttributeError = new DiagnosticDescriptor(
3941
id: "MVVMTK0002",
4042
title: $"Duplicate {nameof(INotifyPropertyChanged)} definition",
4143
messageFormat: $"Cannot apply [ObservableObject] to type {{0}}, as it already declares the {nameof(INotifyPropertyChanged)} interface",
@@ -51,7 +53,7 @@ internal static class DiagnosticDescriptors
5153
/// Format: <c>"Cannot apply [ObservableObjectAttribute] to type {0}, as it already declares the INotifyPropertyChanging interface"</c>.
5254
/// </para>
5355
/// </summary>
54-
public static readonly DiagnosticDescriptor DuplicateINotifyPropertyChangingInterfaceForObservableObjectAttributeError = new(
56+
public static readonly DiagnosticDescriptor DuplicateINotifyPropertyChangingInterfaceForObservableObjectAttributeError = new DiagnosticDescriptor(
5557
id: "MVVMTK0003",
5658
title: $"Duplicate {nameof(INotifyPropertyChanging)} definition",
5759
messageFormat: $"Cannot apply [ObservableObject] to type {{0}}, as it already declares the {nameof(INotifyPropertyChanging)} interface",
@@ -67,7 +69,7 @@ internal static class DiagnosticDescriptors
6769
/// Format: <c>"Cannot apply [ObservableRecipientAttribute] to type {0}, as it already inherits from the ObservableRecipient class"</c>.
6870
/// </para>
6971
/// </summary>
70-
public static readonly DiagnosticDescriptor DuplicateObservableRecipientError = new(
72+
public static readonly DiagnosticDescriptor DuplicateObservableRecipientError = new DiagnosticDescriptor(
7173
id: "MVVMTK0004",
7274
title: "Duplicate ObservableRecipient definition",
7375
messageFormat: $"Cannot apply [ObservableRecipient] to type {{0}}, as it already inherits from the ObservableRecipient class",
@@ -83,7 +85,7 @@ internal static class DiagnosticDescriptors
8385
/// Format: <c>"Cannot apply [ObservableRecipientAttribute] to type {0}, as it lacks necessary base functionality (it should either inherit from ObservableObject, or be annotated with [ObservableObjectAttribute] or [INotifyPropertyChangedAttribute])"</c>.
8486
/// </para>
8587
/// </summary>
86-
public static readonly DiagnosticDescriptor MissingBaseObservableObjectFunctionalityError = new(
88+
public static readonly DiagnosticDescriptor MissingBaseObservableObjectFunctionalityError = new DiagnosticDescriptor(
8789
id: "MVVMTK0005",
8890
title: "Missing base ObservableObject functionality",
8991
messageFormat: $"Cannot apply [ObservableRecipient] to type {{0}}, as it lacks necessary base functionality (it should either inherit from ObservableObject, or be annotated with [ObservableObject] or [INotifyPropertyChanged])",
@@ -99,7 +101,7 @@ internal static class DiagnosticDescriptors
99101
/// Format: <c>"The field {0}.{1} cannot be used to generate an observable property, as it has {2} validation attribute(s) but is declared in a type that doesn't inherit from ObservableValidator"</c>.
100102
/// </para>
101103
/// </summary>
102-
public static readonly DiagnosticDescriptor MissingObservableValidatorInheritanceError = new(
104+
public static readonly DiagnosticDescriptor MissingObservableValidatorInheritanceError = new DiagnosticDescriptor(
103105
id: "MVVMTK0006",
104106
title: "Missing ObservableValidator inheritance",
105107
messageFormat: "The field {0}.{1} cannot be used to generate an observable property, as it has {2} validation attribute(s) but is declared in a type that doesn't inherit from ObservableValidator",
@@ -115,7 +117,7 @@ internal static class DiagnosticDescriptors
115117
/// Format: <c>"The method {0}.{1} cannot be used to generate a command property, as its signature isn't compatible with any of the existing relay command types"</c>.
116118
/// </para>
117119
/// </summary>
118-
public static readonly DiagnosticDescriptor InvalidICommandMethodSignatureError = new(
120+
public static readonly DiagnosticDescriptor InvalidICommandMethodSignatureError = new DiagnosticDescriptor(
119121
id: "MVVMTK0007",
120122
title: "Invalid ICommand method signature",
121123
messageFormat: "The method {0}.{1} cannot be used to generate a command property, as its signature isn't compatible with any of the existing relay command types",
@@ -128,7 +130,7 @@ internal static class DiagnosticDescriptors
128130
/// <summary>
129131
/// Gets a <see cref="DiagnosticDescriptor"/> indicating when an unsupported C# language version is being used.
130132
/// </summary>
131-
public static readonly DiagnosticDescriptor UnsupportedCSharpLanguageVersionError = new(
133+
public static readonly DiagnosticDescriptor UnsupportedCSharpLanguageVersionError = new DiagnosticDescriptor(
132134
id: "MVVMTK0008",
133135
title: "Unsupported C# language version",
134136
messageFormat: "The source generator features from the MVVM Toolkit require consuming projects to set the C# language version to at least C# 8.0",
@@ -144,7 +146,7 @@ internal static class DiagnosticDescriptors
144146
/// Format: <c>"The CanExecute name must refer to a valid member, but "{0}" has no matches in type {1}"</c>.
145147
/// </para>
146148
/// </summary>
147-
public static readonly DiagnosticDescriptor InvalidCanExecuteMemberName = new(
149+
public static readonly DiagnosticDescriptor InvalidCanExecuteMemberName = new DiagnosticDescriptor(
148150
id: "MVVMTK0009",
149151
title: "Invalid ICommand.CanExecute member name",
150152
messageFormat: "The CanExecute name must refer to a valid member, but \"{0}\" has no matches in type {1}",
@@ -160,7 +162,7 @@ internal static class DiagnosticDescriptors
160162
/// Format: <c>"The CanExecute name must refer to a single member, but "{0}" has multiple matches in type {1}"</c>.
161163
/// </para>
162164
/// </summary>
163-
public static readonly DiagnosticDescriptor MultipleCanExecuteMemberNameMatches = new(
165+
public static readonly DiagnosticDescriptor MultipleCanExecuteMemberNameMatches = new DiagnosticDescriptor(
164166
id: "MVVMTK0010",
165167
title: "Multiple ICommand.CanExecute member name matches",
166168
messageFormat: "The CanExecute name must refer to a single member, but \"{0}\" has multiple matches in type {1}",
@@ -176,7 +178,7 @@ internal static class DiagnosticDescriptors
176178
/// Format: <c>"The CanExecute name must refer to a compatible member, but no valid members were found for "{0}" in type {1}"</c>.
177179
/// </para>
178180
/// </summary>
179-
public static readonly DiagnosticDescriptor InvalidCanExecuteMember = new(
181+
public static readonly DiagnosticDescriptor InvalidCanExecuteMember = new DiagnosticDescriptor(
180182
id: "MVVMTK0011",
181183
title: "No valid ICommand.CanExecute member match",
182184
messageFormat: "The CanExecute name must refer to a compatible member, but no valid members were found for \"{0}\" in type {1}",
@@ -192,7 +194,7 @@ internal static class DiagnosticDescriptors
192194
/// Format: <c>"The method {0}.{1} cannot be annotated with the [ICommand] attribute specifying a concurrency control setting, as it maps to a non-asynchronous command type"</c>.
193195
/// </para>
194196
/// </summary>
195-
public static readonly DiagnosticDescriptor InvalidConcurrentExecutionsParameterError = new(
197+
public static readonly DiagnosticDescriptor InvalidConcurrentExecutionsParameterError = new DiagnosticDescriptor(
196198
id: "MVVMTK0012",
197199
title: "Invalid concurrency control setting usage",
198200
messageFormat: "The method {0}.{1} cannot be annotated with the [ICommand] attribute specifying a concurrency control setting, as it maps to a non-asynchronous command type",

CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@
3636

3737
<!-- Enable trimming support on .NET 6 -->
3838
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
39-
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
4039
<IsTrimmable>true</IsTrimmable>
40+
41+
<!-- Workaround for .NET 6.0.x regression (see https://github.com/dotnet/linker/issues/2642), enable again when fixed in SDK -->
42+
<EnableTrimAnalyzer>false</EnableTrimAnalyzer>
4143
</PropertyGroup>
4244

4345
<!-- Source generator project reference for packing -->

0 commit comments

Comments
 (0)