Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes issue where build de-dup doesn't add project analyzers. #11478

Merged
merged 2 commits into from
May 21, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,27 @@ public void RemoveStateSet(ProjectId projectId)
/// </summary>
public ImmutableArray<StateSet> CreateBuildOnlyProjectStateSet(Project project)
{
// create project analyzer reference identity map
var referenceIdentities = project.AnalyzerReferences.Select(r => _analyzerManager.GetAnalyzerReferenceIdentity(r)).ToSet();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v1 and v2 has same implementation. we will remove v1 once update 3 ship.

var stateSetMap = GetStateSets(project).ToDictionary(s => s.Analyzer, s => s);

// now create analyzer to host stateset map
var hostStateSetMap = _hostStates.GetOrCreateStateSets(project.Language).ToDictionary(s => s.Analyzer, s => s);

// initially put all project stateSets in the array
var stateSets = ImmutableArray.CreateBuilder<StateSet>();

// we always include compiler analyzer in build only state
var compilerAnalyzer = _analyzerManager.GetCompilerDiagnosticAnalyzer(project.Language);
StateSet compilerStateSet;
if (stateSetMap.TryGetValue(compilerAnalyzer, out compilerStateSet))
if (hostStateSetMap.TryGetValue(compilerAnalyzer, out compilerStateSet))
{
stateSets.Add(compilerStateSet);
}

// now add all project analyzers
stateSets.AddRange(_projectStates.GetOrUpdateStateSets(project));

// now add analyzers that exist in both host and project
var analyzerMap = _analyzerManager.GetHostDiagnosticAnalyzersPerReference(project.Language);
foreach (var kv in analyzerMap)
{
Expand All @@ -151,7 +159,7 @@ public ImmutableArray<StateSet> CreateBuildOnlyProjectStateSet(Project project)
foreach (var analyzer in kv.Value)
{
StateSet stateSet;
if (stateSetMap.TryGetValue(analyzer, out stateSet) && stateSet != compilerStateSet)
if (hostStateSetMap.TryGetValue(analyzer, out stateSet) && stateSet != compilerStateSet)
{
stateSets.Add(stateSet);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,27 @@ public StateSet GetOrCreateStateSet(Project project, DiagnosticAnalyzer analyzer
/// </summary>
public ImmutableArray<StateSet> CreateBuildOnlyProjectStateSet(Project project)
{
// create project analyzer reference identity map
var referenceIdentities = project.AnalyzerReferences.Select(r => _analyzerManager.GetAnalyzerReferenceIdentity(r)).ToSet();
var stateSetMap = GetStateSets(project).ToDictionary(s => s.Analyzer, s => s);

// now create analyzer to host stateset map
var hostStateSetMap = _hostStates.GetOrCreateStateSets(project.Language).ToDictionary(s => s.Analyzer, s => s);

// initially put all project stateSets in the array
var stateSets = ImmutableArray.CreateBuilder<StateSet>();

// we always include compiler analyzer in build only state
var compilerAnalyzer = _analyzerManager.GetCompilerDiagnosticAnalyzer(project.Language);
StateSet compilerStateSet;
if (stateSetMap.TryGetValue(compilerAnalyzer, out compilerStateSet))
if (hostStateSetMap.TryGetValue(compilerAnalyzer, out compilerStateSet))
{
stateSets.Add(compilerStateSet);
}

// now add all project analyzers
stateSets.AddRange(_projectStates.GetOrUpdateStateSets(project));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was missing.


// now add analyzers that exist in both host and project
var analyzerMap = _analyzerManager.GetHostDiagnosticAnalyzersPerReference(project.Language);
foreach (var kv in analyzerMap)
{
Expand All @@ -142,7 +150,7 @@ public ImmutableArray<StateSet> CreateBuildOnlyProjectStateSet(Project project)
foreach (var analyzer in kv.Value)
{
StateSet stateSet;
if (stateSetMap.TryGetValue(analyzer, out stateSet) && stateSet != compilerStateSet)
if (hostStateSetMap.TryGetValue(analyzer, out stateSet) && stateSet != compilerStateSet)
{
stateSets.Add(stateSet);
}
Expand Down