未验证 提交 7d5f6f4f 编写于 作者: J Jonathon Marolf 提交者: GitHub

Merge pull request #47731 from jmarolf/bugfix/msbuildworkspace-duplicate-analyzer-references

bugfix/msbuildworkspace duplicate analyzer references
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
# nullable enable
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
namespace Microsoft.CodeAnalysis.MSBuild
{
public partial class MSBuildProjectLoader
{
private partial class Worker
{
private class AnalyzerReferencePathComparer : IEqualityComparer<AnalyzerReference?>
{
public static AnalyzerReferencePathComparer Instance = new AnalyzerReferencePathComparer();
private AnalyzerReferencePathComparer() { }
public bool Equals(AnalyzerReference? x, AnalyzerReference? y)
=> string.Equals(x?.FullPath, y?.FullPath, StringComparison.OrdinalIgnoreCase);
public int GetHashCode(AnalyzerReference? obj)
=> obj?.FullPath?.GetHashCode() ?? 0;
}
}
}
}
......@@ -437,7 +437,7 @@ private IEnumerable<AnalyzerReference> ResolveAnalyzerReferences(CommandLineArgu
}
}
return commandLineArgs.ResolveAnalyzerReferences(analyzerLoader);
return commandLineArgs.ResolveAnalyzerReferences(analyzerLoader).Distinct(AnalyzerReferencePathComparer.Instance);
}
private static ImmutableArray<DocumentInfo> CreateDocumentInfos(IReadOnlyList<DocumentFileInfo> documentFileInfos, ProjectId projectId, Encoding? encoding)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册