提交 c4999dac 编写于 作者: J jmarolf

Setting rule defaults per Alex's guidance. (changeset 1365135)

上级 baa43682
......@@ -28,7 +28,7 @@ public sealed class AssemblyAttributesDiagnosticAnalyzer : DiagnosticAnalyzer
FxCopRulesResources.MarkAssembliesWithCLSCompliantAttribute,
FxCopDiagnosticCategory.Design,
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
isEnabledByDefault: false,
description: FxCopRulesResources.MarkAssembliesWithCLSCompliantDescription,
helpLink: "http://msdn.microsoft.com/library/ms182156.aspx",
customTags: DiagnosticCustomTags.Microsoft);
......
......@@ -20,7 +20,7 @@ public abstract class CA1003DiagnosticAnalyzer : DiagnosticAnalyzer
FxCopRulesResources.UseGenericEventHandlerInstances,
FxCopDiagnosticCategory.Design,
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
isEnabledByDefault: false,
helpLink: "http://msdn.microsoft.com/library/ms182178.aspx",
customTags: DiagnosticCustomTags.Microsoft);
......
......@@ -45,7 +45,7 @@ public sealed class CA1008DiagnosticAnalyzer : AbstractNamedTypeAnalyzer
FxCopRulesResources.EnumsShouldZeroValueFlagsRename,
FxCopDiagnosticCategory.Design,
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
isEnabledByDefault: false,
description: FxCopRulesResources.EnumsShouldHaveZeroValueDescription,
helpLink: "http://msdn.microsoft.com/library/ms182149.aspx",
customTags: DiagnosticCustomTags.Microsoft.Concat(RuleRenameCustomTag).ToArray());
......@@ -55,7 +55,7 @@ public sealed class CA1008DiagnosticAnalyzer : AbstractNamedTypeAnalyzer
FxCopRulesResources.EnumsShouldZeroValueFlagsMultipleZero,
FxCopDiagnosticCategory.Design,
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
isEnabledByDefault: false,
description: FxCopRulesResources.EnumsShouldHaveZeroValueDescription,
helpLink: "http://msdn.microsoft.com/library/ms182149.aspx",
customTags: DiagnosticCustomTags.Microsoft.Concat(RuleMultipleZeroCustomTag).ToArray());
......@@ -65,7 +65,7 @@ public sealed class CA1008DiagnosticAnalyzer : AbstractNamedTypeAnalyzer
FxCopRulesResources.EnumsShouldZeroValueNotFlagsNoZeroValue,
FxCopDiagnosticCategory.Design,
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
isEnabledByDefault: false,
description: FxCopRulesResources.EnumsShouldHaveZeroValueDescription,
helpLink: "http://msdn.microsoft.com/library/ms182149.aspx",
customTags: DiagnosticCustomTags.Microsoft.Concat(RuleNoZeroCustomTag).ToArray());
......
......@@ -21,7 +21,7 @@ public sealed class CA1012DiagnosticAnalyzer : AbstractNamedTypeAnalyzer
FxCopRulesResources.TypeIsAbstractButHasPublicConstructors,
FxCopDiagnosticCategory.Design,
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
isEnabledByDefault: false,
helpLink: "http://msdn.microsoft.com/library/ms182126.aspx",
customTags: DiagnosticCustomTags.Microsoft);
......
......@@ -18,7 +18,7 @@ public sealed class CA1017DiagnosticAnalyzer : DiagnosticAnalyzer
"{0}",
FxCopDiagnosticCategory.Design,
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
isEnabledByDefault: false,
description: FxCopRulesResources.MarkAllAssembliesWithComVisibleDescription,
helpLink: "http://msdn.microsoft.com/library/ms182157.aspx",
customTags: DiagnosticCustomTags.Microsoft);
......
......@@ -25,7 +25,7 @@ public abstract class CA1019DiagnosticAnalyzer : AbstractNamedTypeAnalyzer
"{0}",
FxCopDiagnosticCategory.Design,
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
isEnabledByDefault: false,
helpLink: "http://msdn.microsoft.com/library/ms182136.aspx",
customTags: DiagnosticCustomTags.Microsoft);
......
......@@ -23,7 +23,7 @@ public abstract class CA1024DiagnosticAnalyzer<TLanguageKindEnum> : DiagnosticAn
FxCopRulesResources.ChangeToAPropertyIfAppropriate,
FxCopDiagnosticCategory.Design,
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
isEnabledByDefault: false,
description: FxCopRulesResources.UsePropertiesWhereAppropriateDescription,
helpLink: "http://msdn.microsoft.com/library/ms182181.aspx",
customTags: DiagnosticCustomTags.Microsoft);
......
......@@ -21,7 +21,7 @@ public sealed class CA1060DiagnosticAnalyzer : AbstractNamedTypeAnalyzer
FxCopRulesResources.MovePInvokesToNativeMethodsClass,
FxCopDiagnosticCategory.Design,
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
isEnabledByDefault: false,
helpLink: "http://msdn.microsoft.com/library/ms182161.aspx",
customTags: DiagnosticCustomTags.Microsoft);
......
......@@ -38,7 +38,7 @@ public abstract class EnumWithFlagsDiagnosticAnalyzer : AbstractNamedTypeAnalyze
FxCopRulesResources.MarkEnumsWithFlagsMessage,
FxCopDiagnosticCategory.Design,
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
isEnabledByDefault: false,
description: FxCopRulesResources.MarkEnumsWithFlagsDescription,
helpLink: "http://msdn.microsoft.com/library/ms182159.aspx",
customTags: DiagnosticCustomTags.Microsoft);
......@@ -48,7 +48,7 @@ public abstract class EnumWithFlagsDiagnosticAnalyzer : AbstractNamedTypeAnalyze
FxCopRulesResources.DoNotMarkEnumsWithFlagsMessage,
FxCopDiagnosticCategory.Usage,
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
isEnabledByDefault: false,
description: FxCopRulesResources.DoNotMarkEnumsWithFlagsDescription,
helpLink: "http://msdn.microsoft.com/library/ms182335.aspx",
customTags: DiagnosticCustomTags.Microsoft);
......
......@@ -24,7 +24,7 @@ public sealed class StaticTypeRulesDiagnosticAnalyzer : AbstractNamedTypeAnalyze
FxCopRulesResources.StaticHolderTypeIsNotStatic,
FxCopDiagnosticCategory.Usage,
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
isEnabledByDefault: false,
helpLink: "http://msdn.microsoft.com/library/ms182168.aspx",
customTags: DiagnosticCustomTags.Microsoft);
......@@ -33,7 +33,7 @@ public sealed class StaticTypeRulesDiagnosticAnalyzer : AbstractNamedTypeAnalyze
FxCopRulesResources.StaticHolderTypesShouldNotHaveConstructorsMessage,
FxCopDiagnosticCategory.Usage,
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
isEnabledByDefault: false,
helpLink: "http://msdn.microsoft.com/library/ms182169.aspx",
customTags: DiagnosticCustomTags.Microsoft);
......
......@@ -16,7 +16,7 @@ public abstract class CA1309DiagnosticAnalyzer : DiagnosticAnalyzer
FxCopRulesResources.StringComparisonShouldBeOrdinalOrOrdinalIgnoreCase,
FxCopDiagnosticCategory.Globalization,
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
isEnabledByDefault: false,
description: FxCopRulesResources.StringComparisonShouldBeOrdinalDescription,
helpLink: "http://msdn.microsoft.com/library/bb385972.aspx",
customTags: DiagnosticCustomTags.Microsoft);
......
......@@ -28,7 +28,7 @@ public sealed class CA1708DiagnosticAnalyzer : AbstractNamedTypeAnalyzer
FxCopRulesResources.IdentifierNamesShouldDifferMoreThanCase,
FxCopDiagnosticCategory.Naming,
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
isEnabledByDefault: false,
description: FxCopRulesResources.IdentifiersShouldDifferByMoreThanCaseDescription,
helpLink: "http://msdn.microsoft.com/library/ms182242.aspx",
customTags: DiagnosticCustomTags.Microsoft);
......
......@@ -21,7 +21,7 @@ public sealed class CA1813DiagnosticAnalyzer : AbstractNamedTypeAnalyzer
FxCopRulesResources.SealAttributeTypesForImprovedPerf,
FxCopDiagnosticCategory.Performance,
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
isEnabledByDefault: false,
helpLink: "http://msdn.microsoft.com/library/ms182267.aspx",
customTags: DiagnosticCustomTags.Microsoft);
......
......@@ -261,6 +261,8 @@ protected static Diagnostic[] GetSortedDiagnostics(DiagnosticAnalyzer analyzer,
foreach (var project in projects)
{
var compilation = project.GetCompilationAsync().Result;
compilation = EnableAnalyzer(analyzer, compilation);
var diags = compilation.GetAnalyzerDiagnostics(new[] { analyzer });
foreach (var diag in diags)
......@@ -293,10 +295,27 @@ protected static Diagnostic[] GetSortedDiagnostics(DiagnosticAnalyzer analyzer,
return results;
}
private static Compilation EnableAnalyzer(DiagnosticAnalyzer analyzer, Compilation compilation)
{
return compilation
.WithOptions(
compilation
.Options
.WithSpecificDiagnosticOptions(
analyzer
.SupportedDiagnostics
.Select(x =>
KeyValuePair.Create(x.Id, ReportDiagnostic.Default))
.ToImmutableDictionaryOrEmpty()));
}
protected static void AnalyzeDocumentCore(DiagnosticAnalyzer analyzer, Document document, Action<Diagnostic> addDiagnostic, TextSpan? span = null, Func<Exception, DiagnosticAnalyzer, bool> continueOnAnalyzerException = null)
{
var semanticModel = document.GetSemanticModelAsync().Result;
var diagnostics = semanticModel.Compilation.GetAnalyzerDiagnostics(new[] { analyzer }, continueOnAnalyzerException: continueOnAnalyzerException);
var compilation = semanticModel.Compilation;
compilation = EnableAnalyzer(analyzer, compilation);
var diagnostics = compilation.GetAnalyzerDiagnostics(new[] { analyzer }, continueOnAnalyzerException: continueOnAnalyzerException);
foreach (var diagnostic in diagnostics)
{
if (!span.HasValue ||
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册