You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/CodeFixes/ThinktectureRuntimeExtensionsCodeFixProvider.cs
+9Lines changed: 9 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@ public sealed class ThinktectureRuntimeExtensionsCodeFixProvider : CodeFixProvid
11
11
privateconststring_MAKE_PARTIAL="Make the type partial";
12
12
privateconststring_MAKE_METHOD_PARTIAL="Make the method partial";
13
13
privateconststring_MAKE_MEMBER_PUBLIC="Make the member public";
14
+
privateconststring_MAKE_MEMBER_REQUIRED="Make the member required";
14
15
privateconststring_MAKE_FIELD_READONLY="Make the field read-only";
Copy file name to clipboardExpand all lines: src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/Diagnostics/ThinktectureRuntimeExtensionsAnalyzer.cs
+55Lines changed: 55 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,4 @@
1
+
usingMicrosoft.CodeAnalysis.CSharp;
1
2
usingMicrosoft.CodeAnalysis.CSharp.Syntax;
2
3
usingMicrosoft.CodeAnalysis.Diagnostics;
3
4
usingMicrosoft.CodeAnalysis.Operations;
@@ -57,6 +58,7 @@ public sealed class ThinktectureRuntimeExtensionsAnalyzer : DiagnosticAnalyzer
if(context.Nodeis not PropertyDeclarationSyntaxpropertyDeclarationSyntax
87
+
||propertyDeclarationSyntax.ExpressionBodyis not null// public MyStruct Member => ...;
88
+
||propertyDeclarationSyntax.Initializeris not null// public MyStruct Member { get; } = ...;
89
+
||context.ContainingSymbolis not IPropertySymbolpropertySymbol
90
+
||propertySymbol.SetMethodisnull// public MyStruct Member { get; }
91
+
||propertySymbol.IsStatic
92
+
||propertySymbol.DeclaredAccessibility<propertySymbol.ContainingType.DeclaredAccessibility// required members must not be less visible than the containing type
93
+
||propertySymbol.SetMethod.DeclaredAccessibility<propertySymbol.ContainingType.DeclaredAccessibility)// setter of required members must not be less visible than the containing type
if(context.Nodeis not FieldDeclarationSyntaxfieldDeclarationSyntax
102
+
||(fieldDeclarationSyntax.Declaration.Variables.Count==1&&fieldDeclarationSyntax.Declaration.Variables[0].Initializeris not null)// public MyStruct Member = ...;
103
+
||context.ContainingSymbolis not IFieldSymbolfieldSymbol
104
+
||fieldSymbol.IsStatic
105
+
||fieldSymbol.DeclaredAccessibility<fieldSymbol.ContainingType.DeclaredAccessibility)// required members must not be less visible than the containing type
Copy file name to clipboardExpand all lines: src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/DiagnosticsDescriptors.cs
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -48,4 +48,5 @@ internal static class DiagnosticsDescriptors
48
48
publicstaticreadonlyDiagnosticDescriptorStaticPropertiesAreNotConsideredItems=new("TTRESG101","Static properties are not considered enumeration items, use a field instead","The static property '{0}' is not considered a enumeration item, use a field instead",nameof(ThinktectureRuntimeExtensionsAnalyzer),DiagnosticSeverity.Warning,true);
49
49
publicstaticreadonlyDiagnosticDescriptorExplicitComparerWithoutEqualityComparer=new("TTRESG102","The type has a comparer defined but no equality comparer","The type '{0}' has a comparer defined but no equality comparer",nameof(ThinktectureRuntimeExtensionsAnalyzer),DiagnosticSeverity.Warning,true);
50
50
publicstaticreadonlyDiagnosticDescriptorExplicitEqualityComparerWithoutComparer=new("TTRESG103","The type has an equality comparer defined but no comparer","The type '{0}' has an equality comparer defined but no comparer",nameof(ThinktectureRuntimeExtensionsAnalyzer),DiagnosticSeverity.Warning,true);
51
+
publicstaticreadonlyDiagnosticDescriptorMembersDisallowingDefaultValuesMustBeRequired=new("TTRESG104","The member must be marked as 'required' to ensure proper initialization","The {0} '{1}' must be marked as 'required' to ensure proper initialization",nameof(ThinktectureRuntimeExtensionsAnalyzer),DiagnosticSeverity.Warning,true);
0 commit comments