Skip to content

Commit 94cdc24

Browse files
committed
refactor(analyzer): remove resource files and simplify localization
Remove `Resources.Designer.cs` and `Resources.resx`, replacing resource-based localization with hardcoded strings. Update analyzer logic to reference string constants directly. Streamline `_usings.cs` file by removing unused directives. Adjust `.csproj` to exclude removed resource files.
1 parent 4083766 commit 94cdc24

5 files changed

Lines changed: 9 additions & 180 deletions

File tree

DecSm.Analyzers.PublicApiSurface/AT0001_PublicMemberShouldBeAnnotatedWithPublicAPIAnalyzer.cs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,13 @@ public class DSPA0001_PublicMemberShouldBeAnnotatedWithPublicAPIAnalyzer : Diagn
1616
private const string Category = "Design";
1717

1818
// Feel free to use raw strings if you don't need localization.
19-
private static readonly LocalizableString Title = new LocalizableResourceString(nameof(Resources.DSPA0001Title),
20-
Resources.ResourceManager,
21-
typeof(Resources));
19+
private const string Title = "Public member should be annotated with [PublicAPI] or other valid attribute";
2220

2321
// The message that will be displayed to the user.
24-
private static readonly LocalizableString MessageFormat =
25-
new LocalizableResourceString(nameof(Resources.DSPA0001MessageFormat),
26-
Resources.ResourceManager,
27-
typeof(Resources));
22+
private const string MessageFormat = "Public member '{0}' is missing [PublicAPI] or other valid attribute";
2823

29-
private static readonly LocalizableString Description =
30-
new LocalizableResourceString(nameof(Resources.DSPA0001Description),
31-
Resources.ResourceManager,
32-
typeof(Resources));
24+
private const string Description =
25+
"Public members should be annotated with [PublicAPI] to indicate they are part of the public API surface, or another valid attribute.";
3326

3427
private static readonly DiagnosticDescriptor Rule = new(DiagnosticId,
3528
Title,
@@ -124,11 +117,11 @@ private static void AnalyzeSymbol(SymbolAnalysisContext context)
124117
if (symbol is IMethodSymbol methodSymbol)
125118
{
126119
// Skip property/event accessors, as we check the property/event itself
127-
if (methodSymbol.MethodKind == MethodKind.PropertyGet ||
128-
methodSymbol.MethodKind == MethodKind.PropertySet ||
129-
methodSymbol.MethodKind == MethodKind.EventAdd ||
130-
methodSymbol.MethodKind == MethodKind.EventRemove ||
131-
methodSymbol.MethodKind == MethodKind.EventRaise)
120+
if (methodSymbol.MethodKind is MethodKind.PropertyGet
121+
or MethodKind.PropertySet
122+
or MethodKind.EventAdd
123+
or MethodKind.EventRemove
124+
or MethodKind.EventRaise)
132125
return;
133126

134127
if (methodSymbol.IsOverride)

DecSm.Analyzers.PublicApiSurface/DecSm.Analyzers.PublicApiSurface.csproj

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,4 @@
3030
<None Include="$(OutputPath)\$(AssemblyName).xml" Condition="Exists('$(OutputPath)\$(AssemblyName).xml')" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
3131
</ItemGroup>
3232

33-
<ItemGroup>
34-
<EmbeddedResource Update="Resources.resx">
35-
<Generator>ResXFileCodeGenerator</Generator>
36-
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
37-
</EmbeddedResource>
38-
</ItemGroup>
39-
40-
<ItemGroup>
41-
<Compile Update="Resources.Designer.cs">
42-
<DesignTime>True</DesignTime>
43-
<AutoGen>True</AutoGen>
44-
<DependentUpon>Resources.resx</DependentUpon>
45-
</Compile>
46-
</ItemGroup>
47-
4833
</Project>

DecSm.Analyzers.PublicApiSurface/Resources.Designer.cs

Lines changed: 0 additions & 95 deletions
This file was deleted.

DecSm.Analyzers.PublicApiSurface/Resources.resx

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
global using System;
22
global using System.Collections.Immutable;
3-
global using System.Composition;
43
global using System.Linq;
5-
global using System.Threading;
6-
global using System.Threading.Tasks;
74
global using Microsoft.CodeAnalysis;
8-
global using Microsoft.CodeAnalysis.CodeActions;
9-
global using Microsoft.CodeAnalysis.CodeFixes;
10-
global using Microsoft.CodeAnalysis.CSharp;
11-
global using Microsoft.CodeAnalysis.CSharp.Syntax;
125
global using Microsoft.CodeAnalysis.Diagnostics;
13-
global using Microsoft.CodeAnalysis.Formatting;
14-
global using Microsoft.CodeAnalysis.Operations;
15-
global using Microsoft.CodeAnalysis.Text;

0 commit comments

Comments
 (0)