Skip to content

Commit

Permalink
Merge pull request #3961 from mavasani/MultipleFiles
Browse files Browse the repository at this point in the history
Ensure that we do not add duplicate public API files for multi-tfm pr…
  • Loading branch information
mavasani committed Aug 6, 2020
2 parents 17181ac + 0f87aa4 commit 9a179e3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/PublicApiAnalyzers/Core/CodeFixes/DeclarePublicApiFix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,15 @@ protected override async Task<Solution> GetChangedSolutionAsync(CancellationToke
newSolution = newSolution.WithAdditionalDocumentText(pair.Key, pair.Value);
}

// NOTE: We need to avoid creating duplicate files for multi-tfm projects. See https://github.com/dotnet/roslyn-analyzers/issues/3952.
using var uniqueProjectPaths = PooledHashSet<string>.GetInstance();
foreach (KeyValuePair<ProjectId, SourceText> pair in addedPublicSurfaceAreaText)
{
var project = newSolution.GetProject(pair.Key);
newSolution = AddPublicApiFiles(project, pair.Value);
if (uniqueProjectPaths.Add(project.FilePath ?? project.Name))
{
newSolution = AddPublicApiFiles(project, pair.Value);
}
}

return newSolution;
Expand Down

0 comments on commit 9a179e3

Please sign in to comment.