Fixed duplicate diagnostics
This commit is contained in:
parent
5872aa0f0c
commit
20a4b43e4b
1 changed files with 13 additions and 16 deletions
|
@ -46,7 +46,7 @@ namespace Microsoft.Extensions.ProjectModel.Resolution
|
||||||
errorCode = ErrorCodes.NU1001;
|
errorCode = ErrorCodes.NU1001;
|
||||||
message = $"The dependency {FormatLibraryRange(range)} could not be resolved.";
|
message = $"The dependency {FormatLibraryRange(range)} could not be resolved.";
|
||||||
|
|
||||||
AddDiagnostics(messages, library, message, errorCode);
|
AddDiagnostics(messages, library, message, DiagnosticMessageSeverity.Error, errorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -54,7 +54,7 @@ namespace Microsoft.Extensions.ProjectModel.Resolution
|
||||||
errorCode = ErrorCodes.NU1002;
|
errorCode = ErrorCodes.NU1002;
|
||||||
message = $"The dependency {library.Identity} does not support framework {library.Framework}.";
|
message = $"The dependency {library.Identity} does not support framework {library.Framework}.";
|
||||||
|
|
||||||
AddDiagnostics(messages, library, message, errorCode);
|
AddDiagnostics(messages, library, message, DiagnosticMessageSeverity.Error, errorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -84,18 +84,11 @@ namespace Microsoft.Extensions.ProjectModel.Resolution
|
||||||
{
|
{
|
||||||
var message = $"Dependency specified was {range} but ended up with {library.Identity}.";
|
var message = $"Dependency specified was {range} but ended up with {library.Identity}.";
|
||||||
|
|
||||||
foreach (var source in GetRangesWithSourceLocations(library))
|
AddDiagnostics(messages,
|
||||||
{
|
library,
|
||||||
messages.Add(
|
|
||||||
new DiagnosticMessage(
|
|
||||||
ErrorCodes.NU1007,
|
|
||||||
message,
|
message,
|
||||||
source.SourceFilePath,
|
|
||||||
DiagnosticMessageSeverity.Warning,
|
DiagnosticMessageSeverity.Warning,
|
||||||
source.SourceLine,
|
ErrorCodes.NU1007);
|
||||||
source.SourceColumn,
|
|
||||||
library));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,7 +107,11 @@ namespace Microsoft.Extensions.ProjectModel.Resolution
|
||||||
return range.Name + " " + range.VersionRange;
|
return range.Name + " " + range.VersionRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddDiagnostics(List<DiagnosticMessage> messages, LibraryDescription library, string message, string errorCode)
|
private void AddDiagnostics(List<DiagnosticMessage> messages,
|
||||||
|
LibraryDescription library,
|
||||||
|
string message,
|
||||||
|
DiagnosticMessageSeverity severity,
|
||||||
|
string errorCode)
|
||||||
{
|
{
|
||||||
// A (in project.json) -> B (unresolved) (not in project.json)
|
// A (in project.json) -> B (unresolved) (not in project.json)
|
||||||
foreach (var source in GetRangesWithSourceLocations(library).Distinct())
|
foreach (var source in GetRangesWithSourceLocations(library).Distinct())
|
||||||
|
@ -124,7 +121,7 @@ namespace Microsoft.Extensions.ProjectModel.Resolution
|
||||||
errorCode,
|
errorCode,
|
||||||
message,
|
message,
|
||||||
source.SourceFilePath,
|
source.SourceFilePath,
|
||||||
DiagnosticMessageSeverity.Error,
|
severity,
|
||||||
source.SourceLine,
|
source.SourceLine,
|
||||||
source.SourceColumn,
|
source.SourceColumn,
|
||||||
library));
|
library));
|
||||||
|
|
Loading…
Add table
Reference in a new issue