Skip to content

Commit 6afbe69

Browse files
Update analyzer deps / setup (#185)
Removed Vsix project for publishing, now we just package normally as a nuget when building instead. Marked both CodeAnalysis nugets as PrivateAssets so they don't leak into consuming projects. Removed redundant NoParam rule. The rule served no purpose, since _s requires at least one parameter to compile, we do not need an analyzer to validate that. Fixed additional case the Analyzer was missing (passing null when the string contains values to be replaced)
1 parent ba94ad4 commit 6afbe69

9 files changed

Lines changed: 141 additions & 222 deletions

File tree

MN.L10n.Analyzer/MN.L10n.Analyzer.Test/MN.L10n.Analyzer.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<PrivateAssets>all</PrivateAssets>
1212
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1313
</PackageReference>
14-
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.13.0" />
14+
<PackageReference Include="Microsoft.CodeAnalysis" Version="5.3.0" />
1515
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
1616
<PackageReference Include="xunit" Version="2.9.3" />
1717
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">

MN.L10n.Analyzer/MN.L10n.Analyzer.Test/MNL10nAnalyzerUnitTests.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,32 @@ Vänligen bekräfta ditt intresse genom att klicka på länken nedan.
416416
VerifyCSharpDiagnostic(test, expectations.ToArray());
417417
}
418418

419+
[Fact]
420+
public void Test_MN0009_MissingKeywordsWhenArgumentIsNull()
421+
{
422+
var test = @"
423+
namespace ConsoleApplication1
424+
{
425+
class TypeName
426+
{
427+
public void Main() {
428+
_s(""Testing $someParameter$"", null);
429+
}
430+
}
431+
}";
432+
433+
VerifyCSharpDiagnostic(test, new DiagnosticResult
434+
{
435+
Id = "MN0009",
436+
Message = "L10n is missing '$someParameter$' in the object for keywords",
437+
Severity = DiagnosticSeverity.Error,
438+
Locations =
439+
[
440+
new DiagnosticResultLocation("Test0.cs", 7, 6)
441+
]
442+
});
443+
}
444+
419445
protected override CodeFixProvider GetCSharpCodeFixProvider()
420446
{
421447
return new MNL10nCodeFixProvider();

MN.L10n.Analyzer/MN.L10n.Analyzer.Vsix/MN.L10n.Analyzer.Vsix.csproj

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

MN.L10n.Analyzer/MN.L10n.Analyzer.Vsix/source.extension.vsixmanifest

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

MN.L10n.Analyzer/MN.L10n.Analyzer/AnalyzerReleases.Shipped.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
Rule ID | Category | Severity | Notes
99
--------|----------|----------|-------
10-
MN0001 | L10n | Error | MNL10nAnalyzer
1110
MN0002 | L10n | Error | MNL10nAnalyzer
1211
MN0003 | L10n | Error | MNL10nAnalyzer
1312
MN0004 | L10n | Error | MNL10nAnalyzer

MN.L10n.Analyzer/MN.L10n.Analyzer/MN.L10n.Analyzer.csproj

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5-
<IncludeBuildOutput>false</IncludeBuildOutput>
65
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
76
<PublishSingleFile>true</PublishSingleFile>
87
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
8+
<Nullable>enable</Nullable>
9+
<LangVersion>latest</LangVersion>
10+
<IsRoslynComponent>true</IsRoslynComponent>
11+
<IncludeBuildOutput>false</IncludeBuildOutput>
912
</PropertyGroup>
1013

1114
<PropertyGroup>
@@ -21,32 +24,29 @@
2124
<Copyright></Copyright>
2225
<PackageTags>MN.L10n.Analyzer, analyzers</PackageTags>
2326
<NoPackageAnalysis>true</NoPackageAnalysis>
24-
<Version>4.0.2</Version>
27+
<Version>5.0.0</Version>
2528
<Company>MultiNet Interactive AB</Company>
2629
</PropertyGroup>
27-
28-
<PropertyGroup>
29-
<PlatformTarget>x64</PlatformTarget>
30-
</PropertyGroup>
31-
3230
<ItemGroup>
33-
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.13.0" />
34-
<PackageReference Update="NETStandard.Library" PrivateAssets="all" />
31+
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="5.3.0">
32+
<PrivateAssets>all</PrivateAssets>
33+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
34+
</PackageReference>
35+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="5.3.0" PrivateAssets="all" />
3536
</ItemGroup>
3637

3738
<ItemGroup>
3839
<Compile Update="Resources.Designer.cs" DesignTime="True" AutoGen="True" DependentUpon="Resources.resx" />
3940
<EmbeddedResource Update="Resources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" />
4041
</ItemGroup>
4142

42-
<ItemGroup>
43-
<None Update="tools\*.ps1" CopyToOutputDirectory="Always" Pack="true" PackagePath="" />
44-
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
45-
</ItemGroup>
46-
4743
<ItemGroup>
4844
<AdditionalFiles Include="AnalyzerReleases.Shipped.md" />
4945
<AdditionalFiles Include="AnalyzerReleases.Unshipped.md" />
5046
</ItemGroup>
51-
47+
48+
<ItemGroup>
49+
<None Update="tools\*.ps1" CopyToOutputDirectory="Always" Pack="true" PackagePath="" />
50+
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
51+
</ItemGroup>
5252
</Project>

0 commit comments

Comments
 (0)