提交 35ec4746 编写于 作者: M Manish Vasani

Fix some analyzer load diagnostics IDs and a duplicate roslyn diagnostic ID.

Fixes #3805 and #2990
上级 cfb05bda
...@@ -13,7 +13,6 @@ internal static class RoslynDiagnosticIds ...@@ -13,7 +13,6 @@ internal static class RoslynDiagnosticIds
public const string UseArrayEmptyRuleId = "RS0007"; public const string UseArrayEmptyRuleId = "RS0007";
public const string ImplementIEquatableRuleId = "RS0008"; public const string ImplementIEquatableRuleId = "RS0008";
public const string OverrideObjectEqualsRuleId = "RS0009"; public const string OverrideObjectEqualsRuleId = "RS0009";
public const string MissingSharedAttributeRuleId = "RS0010";
public const string DoNotUseVerbatimCrefsRuleId = "RS0010"; public const string DoNotUseVerbatimCrefsRuleId = "RS0010";
public const string CancellationTokenMustBeLastRuleId = "RS0011"; public const string CancellationTokenMustBeLastRuleId = "RS0011";
public const string DoNotCallToImmutableArrayRuleId = "RS0012"; public const string DoNotCallToImmutableArrayRuleId = "RS0012";
...@@ -27,5 +26,6 @@ internal static class RoslynDiagnosticIds ...@@ -27,5 +26,6 @@ internal static class RoslynDiagnosticIds
public const string DeadCodeRuleId = "RS0020"; public const string DeadCodeRuleId = "RS0020";
public const string DeadCodeTriggerRuleId = "RS0021"; public const string DeadCodeTriggerRuleId = "RS0021";
public const string ExposedNoninstantiableTypeRuleId = "RS0022"; public const string ExposedNoninstantiableTypeRuleId = "RS0022";
public const string MissingSharedAttributeRuleId = "RS0023";
} }
} }
...@@ -9,5 +9,11 @@ internal static class IDEDiagnosticIds ...@@ -9,5 +9,11 @@ internal static class IDEDiagnosticIds
public const string SimplifyThisOrMeDiagnosticId = "IDE0003"; public const string SimplifyThisOrMeDiagnosticId = "IDE0003";
public const string RemoveUnnecessaryCastDiagnosticId = "IDE0004"; public const string RemoveUnnecessaryCastDiagnosticId = "IDE0004";
public const string RemoveUnnecessaryImportsDiagnosticId = "IDE0005"; public const string RemoveUnnecessaryImportsDiagnosticId = "IDE0005";
// Analyzer error Ids
public const string AnalyzerChangedId = "IDE1001";
public const string AnalyzerDependencyConflictId = "IDE1002";
public const string MissingAnalyzerReferenceId = "IDE1003";
public const string ErrorReadingRulesetId = "IDE1004";
} }
} }
...@@ -122,8 +122,6 @@ private void LogMissingDependency(MissingAnalyzerDependency missingDependency) ...@@ -122,8 +122,6 @@ private void LogMissingDependency(MissingAnalyzerDependency missingDependency)
private DiagnosticData CreateDiagnostic(ProjectId projectId, AnalyzerDependencyConflict conflict) private DiagnosticData CreateDiagnostic(ProjectId projectId, AnalyzerDependencyConflict conflict)
{ {
string id = ServicesVSResources.WRN_AnalyzerDependencyConflictId;
string category = ServicesVSResources.ErrorCategory;
string message = string.Format( string message = string.Format(
ServicesVSResources.WRN_AnalyzerDependencyConflictMessage, ServicesVSResources.WRN_AnalyzerDependencyConflictMessage,
conflict.AnalyzerFilePath1, conflict.AnalyzerFilePath1,
...@@ -131,8 +129,8 @@ private DiagnosticData CreateDiagnostic(ProjectId projectId, AnalyzerDependencyC ...@@ -131,8 +129,8 @@ private DiagnosticData CreateDiagnostic(ProjectId projectId, AnalyzerDependencyC
conflict.Identity.ToString()); conflict.Identity.ToString());
DiagnosticData data = new DiagnosticData( DiagnosticData data = new DiagnosticData(
id, IDEDiagnosticIds.AnalyzerDependencyConflictId,
category, ServicesVSResources.ErrorCategory,
message, message,
ServicesVSResources.WRN_AnalyzerDependencyConflictMessage, ServicesVSResources.WRN_AnalyzerDependencyConflictMessage,
severity: DiagnosticSeverity.Warning, severity: DiagnosticSeverity.Warning,
...@@ -142,23 +140,22 @@ private DiagnosticData CreateDiagnostic(ProjectId projectId, AnalyzerDependencyC ...@@ -142,23 +140,22 @@ private DiagnosticData CreateDiagnostic(ProjectId projectId, AnalyzerDependencyC
customTags: ImmutableArray<string>.Empty, customTags: ImmutableArray<string>.Empty,
properties: ImmutableDictionary<string, string>.Empty, properties: ImmutableDictionary<string, string>.Empty,
workspace: _workspace, workspace: _workspace,
projectId: projectId); projectId: projectId,
title: ServicesVSResources.WRN_AnalyzerDependencyConflictTitle);
return data; return data;
} }
private DiagnosticData CreateDiagnostic(ProjectId projectId, MissingAnalyzerDependency missingDependency) private DiagnosticData CreateDiagnostic(ProjectId projectId, MissingAnalyzerDependency missingDependency)
{ {
string id = ServicesVSResources.WRN_MissingAnalyzerReferenceId;
string category = ServicesVSResources.ErrorCategory;
string message = string.Format( string message = string.Format(
ServicesVSResources.WRN_MissingAnalyzerReferenceMessage, ServicesVSResources.WRN_MissingAnalyzerReferenceMessage,
missingDependency.AnalyzerPath, missingDependency.AnalyzerPath,
missingDependency.DependencyIdentity.ToString()); missingDependency.DependencyIdentity.ToString());
DiagnosticData data = new DiagnosticData( DiagnosticData data = new DiagnosticData(
id, IDEDiagnosticIds.MissingAnalyzerReferenceId,
category, ServicesVSResources.ErrorCategory,
message, message,
ServicesVSResources.WRN_MissingAnalyzerReferenceMessage, ServicesVSResources.WRN_MissingAnalyzerReferenceMessage,
severity: DiagnosticSeverity.Warning, severity: DiagnosticSeverity.Warning,
...@@ -168,7 +165,8 @@ private DiagnosticData CreateDiagnostic(ProjectId projectId, MissingAnalyzerDepe ...@@ -168,7 +165,8 @@ private DiagnosticData CreateDiagnostic(ProjectId projectId, MissingAnalyzerDepe
customTags: ImmutableArray<string>.Empty, customTags: ImmutableArray<string>.Empty,
properties: ImmutableDictionary<string, string>.Empty, properties: ImmutableDictionary<string, string>.Empty,
workspace: _workspace, workspace: _workspace,
projectId: projectId); projectId: projectId,
title: ServicesVSResources.WRN_MissingAnalyzerReferenceTitle);
return data; return data;
} }
......
...@@ -68,20 +68,19 @@ internal void RemoveAnalyzerAlreadyLoadedDiagnostics(ProjectId projectId, string ...@@ -68,20 +68,19 @@ internal void RemoveAnalyzerAlreadyLoadedDiagnostics(ProjectId projectId, string
private void RaiseAnalyzerChangedWarning(ProjectId projectId, string analyzerPath) private void RaiseAnalyzerChangedWarning(ProjectId projectId, string analyzerPath)
{ {
string id = ServicesVSResources.WRN_AnalyzerChangedId;
string category = ServicesVSResources.ErrorCategory;
string message = string.Format(ServicesVSResources.WRN_AnalyzerChangedMessage, analyzerPath); string message = string.Format(ServicesVSResources.WRN_AnalyzerChangedMessage, analyzerPath);
DiagnosticData data = new DiagnosticData( DiagnosticData data = new DiagnosticData(
id, IDEDiagnosticIds.AnalyzerChangedId,
category, ServicesVSResources.ErrorCategory,
message, message,
ServicesVSResources.WRN_AnalyzerChangedMessage, ServicesVSResources.WRN_AnalyzerChangedMessage,
severity: DiagnosticSeverity.Warning, severity: DiagnosticSeverity.Warning,
isEnabledByDefault: true, isEnabledByDefault: true,
warningLevel: 0, warningLevel: 0,
workspace: _workspace, workspace: _workspace,
projectId: projectId); projectId: projectId,
title: ServicesVSResources.WRN_AnalyzerChangedTitle);
_updateSource.UpdateDiagnosticsForProject(projectId, Tuple.Create(s_analyzerChangedErrorId, analyzerPath), SpecializedCollections.SingletonEnumerable(data)); _updateSource.UpdateDiagnosticsForProject(projectId, Tuple.Create(s_analyzerChangedErrorId, analyzerPath), SpecializedCollections.SingletonEnumerable(data));
} }
......
...@@ -1141,10 +1141,18 @@ protected void UpdateRuleSetError(IRuleSetFile ruleSetFile) ...@@ -1141,10 +1141,18 @@ protected void UpdateRuleSetError(IRuleSetFile ruleSetFile)
} }
else else
{ {
string id = ServicesVSResources.ERR_CantReadRulesetFileId;
string category = ServicesVSResources.ErrorCategory;
string message = string.Format(ServicesVSResources.ERR_CantReadRulesetFileMessage, ruleSetFile.FilePath, ruleSetFile.GetException().Message); string message = string.Format(ServicesVSResources.ERR_CantReadRulesetFileMessage, ruleSetFile.FilePath, ruleSetFile.GetException().Message);
DiagnosticData data = new DiagnosticData(id, category, message, ServicesVSResources.ERR_CantReadRulesetFileMessage, DiagnosticSeverity.Error, true, 0, this.Workspace, this.Id); var data = new DiagnosticData(
id: IDEDiagnosticIds.ErrorReadingRulesetId,
category: ServicesVSResources.ErrorCategory,
message: message,
enuMessageForBingSearch: ServicesVSResources.ERR_CantReadRulesetFileMessage,
severity: DiagnosticSeverity.Error,
isEnabledByDefault: true,
warningLevel: 0,
workspace: this.Workspace,
projectId: this.Id,
title: ServicesVSResources.ERR_CantReadRulesetFileTitle);
this.HostDiagnosticUpdateSource.UpdateDiagnosticsForProject(this.Id, RuleSetErrorId, SpecializedCollections.SingletonEnumerable(data)); this.HostDiagnosticUpdateSource.UpdateDiagnosticsForProject(this.Id, RuleSetErrorId, SpecializedCollections.SingletonEnumerable(data));
} }
......
...@@ -304,20 +304,20 @@ internal class ServicesVSResources { ...@@ -304,20 +304,20 @@ internal class ServicesVSResources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to ErrorReadingRuleset. /// Looks up a localized string similar to Error reading ruleset file {0} - {1}.
/// </summary> /// </summary>
internal static string ERR_CantReadRulesetFileId { internal static string ERR_CantReadRulesetFileMessage {
get { get {
return ResourceManager.GetString("ERR_CantReadRulesetFileId", resourceCulture); return ResourceManager.GetString("ERR_CantReadRulesetFileMessage", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Error reading ruleset file {0} - {1}. /// Looks up a localized string similar to ErrorReadingRuleset.
/// </summary> /// </summary>
internal static string ERR_CantReadRulesetFileMessage { internal static string ERR_CantReadRulesetFileTitle {
get { get {
return ResourceManager.GetString("ERR_CantReadRulesetFileMessage", resourceCulture); return ResourceManager.GetString("ERR_CantReadRulesetFileTitle", resourceCulture);
} }
} }
...@@ -1083,15 +1083,6 @@ internal class ServicesVSResources { ...@@ -1083,15 +1083,6 @@ internal class ServicesVSResources {
} }
} }
/// <summary>
/// Looks up a localized string similar to AnalyzerChangedOnDisk.
/// </summary>
internal static string WRN_AnalyzerChangedId {
get {
return ResourceManager.GetString("WRN_AnalyzerChangedId", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to The analyzer assembly &apos;{0}&apos; has changed. Diagnostics may be incorrect until Visual Studio is restarted.. /// Looks up a localized string similar to The analyzer assembly &apos;{0}&apos; has changed. Diagnostics may be incorrect until Visual Studio is restarted..
/// </summary> /// </summary>
...@@ -1102,11 +1093,11 @@ internal class ServicesVSResources { ...@@ -1102,11 +1093,11 @@ internal class ServicesVSResources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to AnalyzerDependencyConflict. /// Looks up a localized string similar to AnalyzerChangedOnDisk.
/// </summary> /// </summary>
internal static string WRN_AnalyzerDependencyConflictId { internal static string WRN_AnalyzerChangedTitle {
get { get {
return ResourceManager.GetString("WRN_AnalyzerDependencyConflictId", resourceCulture); return ResourceManager.GetString("WRN_AnalyzerChangedTitle", resourceCulture);
} }
} }
...@@ -1120,11 +1111,11 @@ internal class ServicesVSResources { ...@@ -1120,11 +1111,11 @@ internal class ServicesVSResources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to MissingAnalyzerReference. /// Looks up a localized string similar to AnalyzerDependencyConflict.
/// </summary> /// </summary>
internal static string WRN_MissingAnalyzerReferenceId { internal static string WRN_AnalyzerDependencyConflictTitle {
get { get {
return ResourceManager.GetString("WRN_MissingAnalyzerReferenceId", resourceCulture); return ResourceManager.GetString("WRN_AnalyzerDependencyConflictTitle", resourceCulture);
} }
} }
...@@ -1137,6 +1128,15 @@ internal class ServicesVSResources { ...@@ -1137,6 +1128,15 @@ internal class ServicesVSResources {
} }
} }
/// <summary>
/// Looks up a localized string similar to MissingAnalyzerReference.
/// </summary>
internal static string WRN_MissingAnalyzerReferenceTitle {
get {
return ResourceManager.GetString("WRN_MissingAnalyzerReferenceTitle", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to The assembly {0} does not contain any analyzers.. /// Looks up a localized string similar to The assembly {0} does not contain any analyzers..
/// </summary> /// </summary>
......
...@@ -303,13 +303,13 @@ Use the dropdown to view and switch to other projects this file may belong to.</ ...@@ -303,13 +303,13 @@ Use the dropdown to view and switch to other projects this file may belong to.</
<data name="ErrorCategory" xml:space="preserve"> <data name="ErrorCategory" xml:space="preserve">
<value>Roslyn.HostError</value> <value>Roslyn.HostError</value>
</data> </data>
<data name="ERR_CantReadRulesetFileId" xml:space="preserve"> <data name="ERR_CantReadRulesetFileTitle" xml:space="preserve">
<value>ErrorReadingRuleset</value> <value>ErrorReadingRuleset</value>
</data> </data>
<data name="ERR_CantReadRulesetFileMessage" xml:space="preserve"> <data name="ERR_CantReadRulesetFileMessage" xml:space="preserve">
<value>Error reading ruleset file {0} - {1}</value> <value>Error reading ruleset file {0} - {1}</value>
</data> </data>
<data name="WRN_AnalyzerChangedId" xml:space="preserve"> <data name="WRN_AnalyzerChangedTitle" xml:space="preserve">
<value>AnalyzerChangedOnDisk</value> <value>AnalyzerChangedOnDisk</value>
</data> </data>
<data name="WRN_AnalyzerChangedMessage" xml:space="preserve"> <data name="WRN_AnalyzerChangedMessage" xml:space="preserve">
...@@ -441,7 +441,7 @@ Use the dropdown to view and switch to other projects this file may belong to.</ ...@@ -441,7 +441,7 @@ Use the dropdown to view and switch to other projects this file may belong to.</
<data name="PreviewChangesProjectReference" xml:space="preserve"> <data name="PreviewChangesProjectReference" xml:space="preserve">
<value>Project reference to '{0}' in project '{1}'</value> <value>Project reference to '{0}' in project '{1}'</value>
</data> </data>
<data name="WRN_AnalyzerDependencyConflictId" xml:space="preserve"> <data name="WRN_AnalyzerDependencyConflictTitle" xml:space="preserve">
<value>AnalyzerDependencyConflict</value> <value>AnalyzerDependencyConflict</value>
</data> </data>
<data name="WRN_AnalyzerDependencyConflictMessage" xml:space="preserve"> <data name="WRN_AnalyzerDependencyConflictMessage" xml:space="preserve">
...@@ -483,7 +483,7 @@ Use the dropdown to view and switch to other projects this file may belong to.</ ...@@ -483,7 +483,7 @@ Use the dropdown to view and switch to other projects this file may belong to.</
<data name="BuildTableSourceName" xml:space="preserve"> <data name="BuildTableSourceName" xml:space="preserve">
<value>C#/VB Build Table Data Source</value> <value>C#/VB Build Table Data Source</value>
</data> </data>
<data name="WRN_MissingAnalyzerReferenceId" xml:space="preserve"> <data name="WRN_MissingAnalyzerReferenceTitle" xml:space="preserve">
<value>MissingAnalyzerReference</value> <value>MissingAnalyzerReference</value>
</data> </data>
<data name="WRN_MissingAnalyzerReferenceMessage" xml:space="preserve"> <data name="WRN_MissingAnalyzerReferenceMessage" xml:space="preserve">
......
...@@ -122,7 +122,7 @@ public async virtual Task AddDocumentFixesAsync(Document document, ImmutableArra ...@@ -122,7 +122,7 @@ public async virtual Task AddDocumentFixesAsync(Document document, ImmutableArra
}); });
} }
Task.WaitAll(fixerTasks, cancellationToken); await Task.WhenAll(fixerTasks).ConfigureAwait(false);
} }
public virtual async Task<CodeAction> GetFixAsync( public virtual async Task<CodeAction> GetFixAsync(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册