Skip to content

Commit 06f6663

Browse files
committed
Run the status generator directly against the build output
1 parent 0d4b19f commit 06f6663

7 files changed

Lines changed: 18 additions & 146 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/CompilationFailedException.cs

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

StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/Properties/launchSettings.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
"profiles": {
33
"StyleCop.Analyzers.Status.Generator": {
44
"commandName": "Project",
5-
"commandLineArgs": "..\\..\\..\\..\\..\\StyleCopAnalyzers\\StyleCopAnalyzers.sln"
5+
"commandLineArgs": "..\\..\\..\\..\\..\\StyleCopAnalyzers.sln",
6+
"environmentVariables": {
7+
"Configuration": "$(Configuration)"
8+
}
69
}
710
}
8-
}
11+
}

StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/ResourceReader.cs

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

StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/Rules.ruleset

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

StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/SolutionReader.cs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static async Task<SolutionReader> CreateAsync(string pathToSln, string an
7373
reader.SlnPath = pathToSln;
7474
reader.AnalyzerProjectName = analyzerProjectName;
7575
reader.CodeFixProjectName = codeFixProjectName;
76-
reader.workspace = MSBuildWorkspace.Create(properties: new Dictionary<string, string> { { "Configuration", "Release" } });
76+
reader.workspace = MSBuildWorkspace.Create();
7777

7878
await reader.InitializeAsync().ConfigureAwait(false);
7979

@@ -187,7 +187,7 @@ private async Task InitializeAsync()
187187

188188
this.booleanType = this.analyzerCompilation.GetSpecialType(SpecialType.System_Boolean);
189189

190-
this.Compile();
190+
this.LoadAssemblies();
191191

192192
this.noCodeFixAttributeTypeSymbol = this.analyzerCompilation.GetTypeByMetadataName("StyleCop.Analyzers.NoCodeFixAttribute");
193193
this.diagnosticAnalyzerTypeSymbol = this.analyzerCompilation.GetTypeByMetadataName(typeof(DiagnosticAnalyzer).FullName);
@@ -208,26 +208,15 @@ private void InitializeCodeFixTypes()
208208
.ToArray());
209209
}
210210

211-
private void Compile()
211+
private void LoadAssemblies()
212212
{
213-
string path = Path.GetDirectoryName(this.analyzerProject.FilePath);
214-
this.analyzerAssembly = this.GetAssembly(this.analyzerCompilation, ResourceReader.GetResourcesRecursive(path));
215-
216-
this.codeFixAssembly = this.GetAssembly(this.codeFixCompilation);
213+
this.analyzerAssembly = this.GetAssembly(this.analyzerProject);
214+
this.codeFixAssembly = this.GetAssembly(this.codeFixProject);
217215
}
218216

219-
private Assembly GetAssembly(Compilation compilation, IEnumerable<ResourceDescription> manifestResources = null)
217+
private Assembly GetAssembly(Project project)
220218
{
221-
MemoryStream memStream = new MemoryStream();
222-
223-
var emitResult = compilation.Emit(memStream, manifestResources: manifestResources);
224-
225-
if (!emitResult.Success)
226-
{
227-
throw new CompilationFailedException();
228-
}
229-
230-
return Assembly.Load(memStream.ToArray());
219+
return Assembly.LoadFile(project.OutputFilePath);
231220
}
232221

233222
private string GetStatus(INamedTypeSymbol classSymbol, SyntaxNode root, SemanticModel model, DiagnosticDescriptor descriptor)

StyleCopAnalyzers.sln

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,10 @@ EndProject
254254
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StyleCop.Analyzers.Test.CSharp7", "StyleCop.Analyzers\StyleCop.Analyzers.Test.CSharp7\StyleCop.Analyzers.Test.CSharp7.csproj", "{F10E4AEF-86A2-4394-8B6F-1A3468B72F1D}"
255255
EndProject
256256
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StyleCop.Analyzers.Status.Generator", "StyleCop.Analyzers\StyleCop.Analyzers.Status.Generator\StyleCop.Analyzers.Status.Generator.csproj", "{80EA831D-D993-44A8-BB77-33D84BACE711}"
257+
ProjectSection(ProjectDependencies) = postProject
258+
{F91F7815-4E63-4698-B053-E57B2D707194} = {F91F7815-4E63-4698-B053-E57B2D707194}
259+
{3B052737-06CE-4182-AE0F-08EB82DFA73E} = {3B052737-06CE-4182-AE0F-08EB82DFA73E}
260+
EndProjectSection
257261
EndProject
258262
Global
259263
GlobalSection(SolutionConfigurationPlatforms) = preSolution

appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ test_script:
1212
- ps: .\opencover-report.ps1 -Debug -NoBuild -NoReport -AppVeyor
1313
- cd ..
1414
- .\packages\Codecov.1.0.1\tools\codecov.exe -f ".\build\OpenCover.Reports\OpenCover.StyleCopAnalyzers.xml"
15+
- .\StyleCop.Analyzers\StyleCop.Analyzers.Status.Generator\bin\Debug\net46\StyleCop.Analyzers.Status.Generator.exe .\StyleCopAnalyzers.sln > StyleCop.Analyzers.Status.json
1516
cache:
1617
- packages -> **\packages.config
1718
- C:\Users\appveyor\.nuget\packages -> appveyor.yml
1819
artifacts:
1920
- path: 'StyleCop.Analyzers\**\*.vsix'
2021
- path: 'StyleCop.Analyzers\**\*.nupkg'
22+
- path: 'StyleCop.Analyzers.Status.json'

0 commit comments

Comments
 (0)