Skip to content

Commit

Permalink
Don't add duplicate source files to project
Browse files Browse the repository at this point in the history
  • Loading branch information
DustinCampbell committed Dec 16, 2016
1 parent f71a08d commit ef4b383
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,26 +199,10 @@ public static ProjectFileInfo Create(
var noWarn = PropertyConverter.ToSuppressDiagnostics(projectInstance.GetPropertyValue(PropertyNames.NoWarn));
var outputPath = projectInstance.GetPropertyValue(PropertyNames.OutputPath);

var sourceFiles = projectInstance
.GetItems(ItemNames.Compile)
.Select(GetFullPath)
.ToList();

var references = projectInstance
.GetItems(ItemNames.ReferencePath)
.Where(ReferenceSourceTargetIsProjectReference)
.Select(GetFullPath)
.ToList();

var projectReferences = projectInstance
.GetItems(ItemNames.ProjectReference)
.Select(GetFullPath)
.ToList();

var analyzers = projectInstance
.GetItems(ItemNames.Analyzer)
.Select(GetFullPath)
.ToList();
var sourceFiles = GetFullPaths(projectInstance.GetItems(ItemNames.Compile));
var references = GetFullPaths(projectInstance.GetItems(ItemNames.ReferencePath));
var projectReferences = GetFullPaths(projectInstance.GetItems(ItemNames.ProjectReference));
var analyzers = GetFullPaths(projectInstance.GetItems(ItemNames.Analyzer));

return new ProjectFileInfo(
projectFilePath, assemblyName, name, new FrameworkName(targetFrameworkMoniker), targetFrameworks, specifiedLanguageVersion,
Expand All @@ -232,9 +216,16 @@ private static bool ReferenceSourceTargetIsProjectReference(ProjectItemInstance
return !string.Equals(projectItem.GetMetadataValue(MetadataNames.ReferenceSourceTarget), ItemNames.ProjectReference, StringComparison.OrdinalIgnoreCase);
}

private static string GetFullPath(ProjectItemInstance projectItem)
private static IList<string> GetFullPaths(ICollection<ProjectItemInstance> items)
{
return projectItem.GetMetadataValue(MetadataNames.FullPath);
var sortedSet = new SortedSet<string>(StringComparer.OrdinalIgnoreCase);

foreach (var item in items)
{
sortedSet.Add(item.GetMetadataValue(MetadataNames.FullPath));
}

return sortedSet.ToList();
}
}
}

0 comments on commit ef4b383

Please sign in to comment.