Skip to content

Commit 863ad3d

Browse files
committed
Removed the diagnostic for a missing manifest file.
1 parent fe32497 commit 863ad3d

File tree

7 files changed

+47
-91
lines changed

7 files changed

+47
-91
lines changed

src/Community.VisualStudio.SourceGenerators/CommandTable/CommandTableGenerator.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,17 @@ namespace Community.VisualStudio.SourceGenerators;
99
public class CommandTableGenerator : GeneratorBase, ISourceGenerator
1010
{
1111
private static readonly DiagnosticDescriptor _invalidCommandTableFile = new(
12-
DiagnosticIds.CVSSG004_InvalidCommandTableFile,
13-
new LocalizableResourceString(nameof(Resources.CVSSG004_Title), Resources.ResourceManager, typeof(Resources)),
14-
new LocalizableResourceString(nameof(Resources.CVSSG004_MessageFormat), Resources.ResourceManager, typeof(Resources)),
12+
DiagnosticIds.CVSSG003_InvalidCommandTableFile,
13+
new LocalizableResourceString(nameof(Resources.CVSSG003_InvalidCommandTableFile_Title), Resources.ResourceManager, typeof(Resources)),
14+
new LocalizableResourceString(nameof(Resources.CVSSG003_InvalidCommandTableFile_MessageFormat), Resources.ResourceManager, typeof(Resources)),
1515
CommonDiagnostics.Category,
1616
DiagnosticSeverity.Error,
1717
true
1818
);
1919

2020
private static readonly DiagnosticDescriptor _duplicateSymbol = new(
21-
DiagnosticIds.CVSSG005_DuplicateSymbol,
22-
new LocalizableResourceString(nameof(Resources.CVSSG005_Title), Resources.ResourceManager, typeof(Resources)),
23-
new LocalizableResourceString(nameof(Resources.CVSSG005_MessageFormat), Resources.ResourceManager, typeof(Resources)),
21+
DiagnosticIds.CVSSG004_DuplicateSymbol,
22+
new LocalizableResourceString(nameof(Resources.CVSSG004_DuplicateSymbol_Title), Resources.ResourceManager, typeof(Resources)),
2423
CommonDiagnostics.Category,
2524
DiagnosticSeverity.Error,
2625
true

src/Community.VisualStudio.SourceGenerators/CommonDiagnostics.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ internal static class CommonDiagnostics
77
internal const string Category = "VSIX";
88

99
internal static readonly DiagnosticDescriptor NoNamespace = new(
10-
DiagnosticIds.CVSSG003_NoNamespace,
11-
new LocalizableResourceString(nameof(Resources.CVSSG003_Title), Resources.ResourceManager, typeof(Resources)),
12-
new LocalizableResourceString(nameof(Resources.CVSSG003_MessageFormat), Resources.ResourceManager, typeof(Resources)),
10+
DiagnosticIds.CVSSG001_NoNamespace,
11+
new LocalizableResourceString(nameof(Resources.CVSSG001_NoNamespace_Title), Resources.ResourceManager, typeof(Resources)),
12+
new LocalizableResourceString(nameof(Resources.CVSSG001_NoNamespace_MessageFormat), Resources.ResourceManager, typeof(Resources)),
1313
Category,
1414
DiagnosticSeverity.Error,
1515
true

src/Community.VisualStudio.SourceGenerators/DiagnosticIds.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
internal static class DiagnosticIds
44
{
5-
public const string CVSSG001_ManifestFileNotFound = "CVSSG001";
5+
public const string CVSSG001_NoNamespace = "CVSSG001";
66
public const string CVSSG002_InvalidManifestFile = "CVSSG002";
7-
public const string CVSSG003_NoNamespace = "CVSSG003";
8-
public const string CVSSG004_InvalidCommandTableFile = "CVSSG004";
9-
public const string CVSSG005_DuplicateSymbol = "CVSSG005";
7+
public const string CVSSG003_InvalidCommandTableFile = "CVSSG003";
8+
public const string CVSSG004_DuplicateSymbol = "CVSSG004";
109
}

src/Community.VisualStudio.SourceGenerators/Manifest/ManifestGenerator.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,10 @@ public class ManifestGenerator : GeneratorBase, ISourceGenerator
99
{
1010
private const string _manifestFileName = "source.extension.vsixmanifest";
1111

12-
private static readonly DiagnosticDescriptor _manifestFileNotFound = new(
13-
DiagnosticIds.CVSSG001_ManifestFileNotFound,
14-
new LocalizableResourceString(nameof(Resources.CVSSG001_Title), Resources.ResourceManager, typeof(Resources)),
15-
new LocalizableResourceString(nameof(Resources.CVSSG001_MessageFormat), Resources.ResourceManager, typeof(Resources)),
16-
CommonDiagnostics.Category,
17-
DiagnosticSeverity.Error,
18-
true
19-
);
20-
2112
private static readonly DiagnosticDescriptor _invalidManifestFile = new(
2213
DiagnosticIds.CVSSG002_InvalidManifestFile,
23-
new LocalizableResourceString(nameof(Resources.CVSSG002_Title), Resources.ResourceManager, typeof(Resources)),
24-
new LocalizableResourceString(nameof(Resources.CVSSG002_MessageFormat), Resources.ResourceManager, typeof(Resources)),
14+
new LocalizableResourceString(nameof(Resources.CVSSG002_InvalidManifestFile_Title), Resources.ResourceManager, typeof(Resources)),
15+
new LocalizableResourceString(nameof(Resources.CVSSG002_InvalidManifestFile_MessageFormat), Resources.ResourceManager, typeof(Resources)),
2516
CommonDiagnostics.Category,
2617
DiagnosticSeverity.Error,
2718
true

src/Community.VisualStudio.SourceGenerators/Resources.Designer.cs

Lines changed: 19 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Community.VisualStudio.SourceGenerators/Resources.resx

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -117,38 +117,32 @@
117117
<resheader name="writer">
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120-
<data name="CVSSG001_MessageFormat" xml:space="preserve">
121-
<value>The project does not contain a 'source.extension.vsixmanifest' file</value>
120+
<data name="CVSSG001_NoNamespace_MessageFormat" xml:space="preserve">
121+
<value>The project does not have a root namespace and a namespace was not specified against the AdditionalFiles item for {0}</value>
122+
<comment>{0} = Additional file name</comment>
122123
</data>
123-
<data name="CVSSG001_Title" xml:space="preserve">
124-
<value>Project should contain a VSIX manifest file</value>
124+
<data name="CVSSG001_NoNamespace_Title" xml:space="preserve">
125+
<value>Namespace must be specified for generated code</value>
125126
</data>
126-
<data name="CVSSG002_MessageFormat" xml:space="preserve">
127+
<data name="CVSSG002_InvalidManifestFile_MessageFormat" xml:space="preserve">
127128
<value>The 'source.extension.vsixmanifest' file is invalid: {0}</value>
128129
<comment>{0} = Error message</comment>
129130
</data>
130-
<data name="CVSSG002_Title" xml:space="preserve">
131+
<data name="CVSSG002_InvalidManifestFile_Title" xml:space="preserve">
131132
<value>VSIX manifest file should be valid</value>
132133
</data>
133-
<data name="CVSSG003_MessageFormat" xml:space="preserve">
134-
<value>The project does not have a root namespace and a namespace was not specified against the AdditionalFiles item for {0}</value>
135-
<comment>{0} = Additional file name</comment>
136-
</data>
137-
<data name="CVSSG003_Title" xml:space="preserve">
138-
<value>Namespace must be specified for generated code</value>
139-
</data>
140-
<data name="CVSSG004_MessageFormat" xml:space="preserve">
134+
<data name="CVSSG003_InvalidCommandTableFile_MessageFormat" xml:space="preserve">
141135
<value>The command table file '{0}' is invalid: {1}</value>
142136
<comment>{0} = File name; {1} = Error message</comment>
143137
</data>
144-
<data name="CVSSG004_Title" xml:space="preserve">
138+
<data name="CVSSG003_InvalidCommandTableFile_Title" xml:space="preserve">
145139
<value>Command table file shuld be valid</value>
146140
</data>
147-
<data name="CVSSG005_MessageFormat" xml:space="preserve">
141+
<data name="CVSSG004_DuplicateSymbol_MessageFormat" xml:space="preserve">
148142
<value>The symbol '{0}' is defined multiple times with different values</value>
149143
<comment>{0} = Symbol name</comment>
150144
</data>
151-
<data name="CVSSG005_Title" xml:space="preserve">
145+
<data name="CVSSG004_DuplicateSymbol_Title" xml:space="preserve">
152146
<value>Symbols in command tables should be unique</value>
153147
</data>
154148
<data name="Error_CouldNotParseManifest" xml:space="preserve">
@@ -160,7 +154,7 @@
160154
<comment>{0} = Symbol name</comment>
161155
</data>
162156
<data name="Error_InvalidIdSymbol" xml:space="preserve">
163-
<value>The IDSymbol named '{0}' cannot be parsed as a hexadecimal number.</value>
157+
<value>The IDSymbol named '{0}' cannot be parsed as a hexadecimal or integer number.</value>
164158
<comment>{0} = Symbol name</comment>
165159
</data>
166160
<data name="Error_ManifestNodeNotFound" xml:space="preserve">

test/Community.VisualStudio.SourceGenerators.UnitTests/Manifest/ManifestGeneratorTests.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,11 @@ public class ManifestGeneratorTests : GeneratorTestBase
99
{
1010
protected override ISourceGenerator CreateGenerator() => new ManifestGenerator();
1111

12-
[Fact]
13-
public async Task ShouldReportDiagnosticWhenManifestFileIsNotFoundAsync()
14-
{
15-
ImmutableArray<Diagnostic> diagnostics;
16-
(_, diagnostics) = await RunGeneratorAsync().ConfigureAwait(false);
17-
18-
Diagnostic diagnostic = Assert.Single(diagnostics);
19-
Assert.Equal("CVSSG001", diagnostic.Id);
20-
Assert.Equal(DiagnosticSeverity.Error, diagnostic.Severity);
21-
}
22-
2312
[Fact]
2413
public async Task ShouldReportDiagnosticWhenManifestFileIsInvalidAsync()
2514
{
15+
SetProjectProperty("RootNamespace", "Root");
16+
2617
await WriteManifestAsync(@"
2718
<PackageManifest Version='2.0.0' xmlns='http://schemas.microsoft.com/developer/vsx-schema/2011'>
2819
<Metadata/>
@@ -56,7 +47,7 @@ await WriteManifestAsync(@"
5647
(_, diagnostics) = await RunGeneratorAsync().ConfigureAwait(false);
5748

5849
Diagnostic diagnostic = Assert.Single(diagnostics);
59-
Assert.Equal("CVSSG003", diagnostic.Id);
50+
Assert.Equal("CVSSG001", diagnostic.Id);
6051
Assert.Equal(DiagnosticSeverity.Error, diagnostic.Severity);
6152
}
6253

0 commit comments

Comments
 (0)