提交 6380632c 编写于 作者: M manishv

Remove need for two attributes on diagnostic analyzers.

Current design of DiagnosticAnalyzers require each analyzer type to have 2 attributes:
1) DiagnosticAnalyzerAttribute: This is defined in Microsoft.CodeAnalysis and is used by
  (a) Command line compilers to detect analyzer types in analyzer assemblies.
  (b) MSBuild and IDE to detect per-project analyzers specified in the project file.
2) ExportDiagnosticAnalyzerAttribute: This is a MEF Export attribute used by the IDE to detect analyzers installed by VSIX extensions and to be used across the entire VS session.

Having two attributes for the same purpose, but for different hosts is redundant. This change includes the following:

1) Change the VSIX based analyzer model to use the VSIX manifest file to specify the analyzer assemblies. The manifest file can specify an "Asset" tag with Type "Microsoft.VisualStudio.Analyzer" to explicitly specify an analyzer asset. IDE will treat these assemblies as analyzer file references for the workspace session and detect analyzers using the compiler layer DiagnosticAnalyzerAttribute.

2) Change DiagnosticAnalyzerAttribute constructor to take a params array of supported languages. Language specific diagnostic analyzers can specify explicit set of supported languages, and all the analyzer hosts will skip loading analyzers for unsupported languages (changeset 1322657)
上级 988d95a0
......@@ -9,6 +9,7 @@
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
......@@ -421,7 +422,11 @@ each error
protected override bool TryGetCompilerDiagnosticCode(string diagnosticId, out uint code)
{
return CommonCompiler.TryGetCompilerDiagnosticCode(diagnosticId, "CS", out code);
}
protected override ImmutableArray<IDiagnosticAnalyzer> ResolveAnalyzersFromArguments(List<DiagnosticInfo> diagnostics, CommonMessageProvider messageProvider, TouchedFileLogger touchedFiles)
{
return Arguments.ResolveAnalyzersFromArguments(LanguageNames.CSharp, diagnostics, messageProvider, touchedFiles);
}
}
}
......@@ -28,7 +28,7 @@ public sealed partial class AnalyzerFileReference : AnalyzerReference
private string displayName;
private ImmutableArray<IDiagnosticAnalyzer>? lazyAnalyzers;
private Assembly assembly;
/// <summary>
/// Fired when an <see cref="Assembly"/> referred to by an <see cref="AnalyzerFileReference"/>
/// (or a dependent <see cref="Assembly"/>) is loaded.
......@@ -81,6 +81,21 @@ public override ImmutableArray<IDiagnosticAnalyzer> GetAnalyzers()
return lazyAnalyzers.Value;
}
public override ImmutableArray<IDiagnosticAnalyzer> GetAnalyzersForLanguage(string language)
{
if (string.IsNullOrEmpty(language))
{
throw new ArgumentException("language");
}
if (!lazyAnalyzers.HasValue)
{
lazyAnalyzers = MetadataCache.GetOrCreateAnalyzersFromFile(this, language);
}
return lazyAnalyzers.Value;
}
public override string FullPath
{
get
......@@ -119,25 +134,10 @@ public override string Display
}
}
/// <summary>
/// Returns the <see cref="ImmutableArray{T}"/> of <see cref="IDiagnosticAnalyzer"/> defined in the given <paramref name="analyzerAssemblies"/>.
/// </summary>
public static ImmutableArray<IDiagnosticAnalyzer> GetAnalyzers(ImmutableArray<AnalyzerFileReference> analyzerAssemblies)
{
var builder = ImmutableArray.CreateBuilder<IDiagnosticAnalyzer>();
foreach (var analyzerAssembly in analyzerAssemblies)
{
analyzerAssembly.AddAnalyzers(builder, diagnosticsOpt: null, messageProviderOpt: null);
}
return builder.ToImmutable();
}
/// <summary>
/// Adds the <see cref="ImmutableArray{T}"/> of <see cref="IDiagnosticAnalyzer"/> defined in this assembly reference.
/// </summary>
internal void AddAnalyzers(ImmutableArray<IDiagnosticAnalyzer>.Builder builder, List<DiagnosticInfo> diagnosticsOpt, CommonMessageProvider messageProviderOpt)
internal void AddAnalyzers(ImmutableArray<IDiagnosticAnalyzer>.Builder builder, List<DiagnosticInfo> diagnosticsOpt, CommonMessageProvider messageProviderOpt, string languageOpt = null)
{
// We handle loading of analyzer assemblies ourselves. This allows us to avoid locking the assembly
// file on disk.
......@@ -188,12 +188,17 @@ internal void AddAnalyzers(ImmutableArray<IDiagnosticAnalyzer>.Builder builder,
{
try
{
if (type.GetTypeInfo().ImplementedInterfaces.Contains(typeof(IDiagnosticAnalyzer)) && type.IsDefined(typeof(DiagnosticAnalyzerAttribute)))
if (type.GetTypeInfo().ImplementedInterfaces.Contains(typeof(IDiagnosticAnalyzer)))
{
var attribute = type.GetCustomAttribute<DiagnosticAnalyzerAttribute>();
if (attribute != null &&
(languageOpt == null || attribute.IsSupported(languageOpt)))
{
hasAnalyzers = true;
builder.Add((IDiagnosticAnalyzer)Activator.CreateInstance(type));
}
}
}
catch (Exception e)
{
if (diagnosticsOpt != null && messageProviderOpt != null)
......
......@@ -331,7 +331,7 @@ public IEnumerable<AnalyzerReference> ResolveAnalyzerReferences()
}
}
internal ImmutableArray<IDiagnosticAnalyzer> ResolveAnalyzersFromArguments(List<DiagnosticInfo> diagnostics, CommonMessageProvider messageProvider, TouchedFileLogger touchedFiles)
internal ImmutableArray<IDiagnosticAnalyzer> ResolveAnalyzersFromArguments(string language, List<DiagnosticInfo> diagnostics, CommonMessageProvider messageProvider, TouchedFileLogger touchedFiles)
{
var builder = ImmutableArray.CreateBuilder<IDiagnosticAnalyzer>();
foreach (var reference in AnalyzerReferences)
......@@ -339,7 +339,7 @@ internal ImmutableArray<IDiagnosticAnalyzer> ResolveAnalyzersFromArguments(List<
var resolvedReference = ResolveAnalyzerReference(reference);
if (resolvedReference != null)
{
resolvedReference.AddAnalyzers(builder, diagnostics, messageProvider);
resolvedReference.AddAnalyzers(builder, diagnostics, messageProvider, language);
}
else
{
......
......@@ -53,6 +53,7 @@ protected static string ResponseFileDirectory
protected abstract uint GetSqmAppID();
protected abstract bool TryGetCompilerDiagnosticCode(string diagnosticId, out uint code);
protected abstract void CompilerSpecificSqm(IVsSqmMulti sqm, uint sqmSession);
protected abstract ImmutableArray<IDiagnosticAnalyzer> ResolveAnalyzersFromArguments(List<DiagnosticInfo> diagnostics, CommonMessageProvider messageProvider, TouchedFileLogger touchedFiles);
public CommonCompiler(CommandLineParser parser, string responseFile, string[] args, string baseDirectory, string additionalReferencePaths)
{
......@@ -276,7 +277,7 @@ public virtual int Run(TextWriter consoleOutput, CancellationToken cancellationT
}
var diagnostics = new List<DiagnosticInfo>();
var analyzers = Arguments.ResolveAnalyzersFromArguments(diagnostics, MessageProvider, touchedFilesLogger);
var analyzers = ResolveAnalyzersFromArguments(diagnostics, MessageProvider, touchedFilesLogger);
if (PrintErrors(diagnostics, consoleOutput))
{
return Failed;
......
......@@ -701,7 +701,7 @@ internal static Metadata GetOrCreateFromFile(string fullPath, MetadataImageKind
}
}
internal static ImmutableArray<IDiagnosticAnalyzer> GetOrCreateAnalyzersFromFile(AnalyzerFileReference analyzerReference)
internal static ImmutableArray<IDiagnosticAnalyzer> GetOrCreateAnalyzersFromFile(AnalyzerFileReference analyzerReference, string langauge = null)
{
string fullPath = analyzerReference.FullPath;
Debug.Assert(PathUtilities.IsAbsolute(fullPath));
......@@ -729,7 +729,7 @@ internal static ImmutableArray<IDiagnosticAnalyzer> GetOrCreateAnalyzersFromFile
// get all analyzers in the assembly:
var builder = ImmutableArray.CreateBuilder<IDiagnosticAnalyzer>();
analyzerReference.AddAnalyzers(builder, null, null);
analyzerReference.AddAnalyzers(builder, null, null, langauge);
var analyzers = builder.ToImmutable();
// refresh the timestamp (the file may have changed just before we memory-mapped it):
......
......@@ -35,6 +35,11 @@ public override ImmutableArray<IDiagnosticAnalyzer> GetAnalyzers()
return this.analyzers;
}
public override ImmutableArray<IDiagnosticAnalyzer> GetAnalyzersForLanguage(string language)
{
return this.analyzers;
}
public override string FullPath
{
get
......
......@@ -40,5 +40,6 @@ public virtual bool IsUnresolved
}
public abstract ImmutableArray<IDiagnosticAnalyzer> GetAnalyzers();
public abstract ImmutableArray<IDiagnosticAnalyzer> GetAnalyzersForLanguage(string language);
}
}
\ No newline at end of file
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Immutable;
namespace Microsoft.CodeAnalysis.Diagnostics
{
/// <summary>
/// Place this onto a class to cause it to be considered a diagnostic analyzer when loaded by the command-line compiler.
/// Place this attribute onto a type to cause it to be considered a diagnostic analyzer.
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public sealed class DiagnosticAnalyzerAttribute : Attribute
{
/// <summary>
/// Analyzer attribute to be used for diagnostic analyzer.
/// If the analyzer is langauge agnostic, then <paramref name="supportedLanguages"/> can be empty.
/// Otherwise, if the analyzer is language specific, then specify the set of supported languages from <see cref="LanguageNames"/>.
/// </summary>
public DiagnosticAnalyzerAttribute(params string[] supportedLanguages)
{
this.SupportedLanguages = supportedLanguages.AsImmutableOrEmpty();
}
public ImmutableArray<string> SupportedLanguages { get; private set; }
internal bool IsSupported(string language)
{
return this.SupportedLanguages.IsEmpty || this.SupportedLanguages.Contains(language);
}
}
}
\ No newline at end of file
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Immutable;
namespace Microsoft.CodeAnalysis.Diagnostics
......@@ -43,5 +44,10 @@ public override ImmutableArray<IDiagnosticAnalyzer> GetAnalyzers()
{
return ImmutableArray<IDiagnosticAnalyzer>.Empty;
}
public override ImmutableArray<IDiagnosticAnalyzer> GetAnalyzersForLanguage(string language)
{
return ImmutableArray<IDiagnosticAnalyzer>.Empty;
}
}
}
......@@ -5,6 +5,7 @@ Imports System.IO
Imports System.Reflection
Imports System.Text
Imports System.Threading.Tasks
Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.Instrumentation
Namespace Microsoft.CodeAnalysis.VisualBasic
......@@ -337,6 +338,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Protected Overrides Function TryGetCompilerDiagnosticCode(diagnosticId As String, ByRef code As UInteger) As Boolean
Return CommonCompiler.TryGetCompilerDiagnosticCode(diagnosticId, "BC", code)
End Function
Protected Overrides Function ResolveAnalyzersFromArguments(diagnostics As List(Of DiagnosticInfo), messageProvider As CommonMessageProvider, touchedFiles As TouchedFileLogger) As ImmutableArray(Of IDiagnosticAnalyzer)
Return Arguments.ResolveAnalyzersFromArguments(LanguageNames.VisualBasic, diagnostics, messageProvider, touchedFiles)
End Function
End Class
End Namespace
......@@ -6687,7 +6687,7 @@ End Module"
End Sub
End Class
<DiagnosticAnalyzer>
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
MustInherit Class MockAbstractDiagnosticAnalyzer
Implements ICompilationNestedAnalyzerFactory, ICompilationAnalyzer
......@@ -6696,7 +6696,7 @@ End Module"
Public MustOverride Sub AnalyzeCompilation(compilation As Compilation, addDiagnostic As Action(Of Diagnostic), options As AnalyzerOptions, cancellationToken As CancellationToken) Implements ICompilationAnalyzer.AnalyzeCompilation
End Class
<DiagnosticAnalyzer>
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
Class HiddenDiagnosticAnalyzer
Inherits MockAbstractDiagnosticAnalyzer
Implements ISyntaxNodeAnalyzer(Of SyntaxKind)
......@@ -6727,7 +6727,7 @@ End Module"
End Sub
End Class
<DiagnosticAnalyzer>
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
Class InfoDiagnosticAnalyzer
Inherits MockAbstractDiagnosticAnalyzer
Implements ISyntaxNodeAnalyzer(Of SyntaxKind)
......@@ -6759,7 +6759,7 @@ End Module"
End Sub
End Class
<DiagnosticAnalyzer>
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
Class WarningDiagnosticAnalyzer
Inherits MockAbstractDiagnosticAnalyzer
Implements ISymbolAnalyzer
......@@ -6793,7 +6793,7 @@ End Module"
End Sub
End Class
<DiagnosticAnalyzer>
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
Class ErrorDiagnosticAnalyzer
Inherits MockAbstractDiagnosticAnalyzer
Implements ISyntaxNodeAnalyzer(Of SyntaxKind)
......
......@@ -5,7 +5,7 @@
namespace Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers.Design
{
[DiagnosticAnalyzer]
[DiagnosticAnalyzer(LanguageNames.CSharp)]
[ExportDiagnosticAnalyzer(LanguageNames.CSharp)]
public class CSharpCA1003DiagnosticAnalyzer : CA1003DiagnosticAnalyzer
{
......
......@@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers.Design
/// Cause:
/// In its constructor, an attribute defines arguments that do not have corresponding properties.
/// </summary>
[DiagnosticAnalyzer]
[DiagnosticAnalyzer(LanguageNames.CSharp)]
[ExportDiagnosticAnalyzer(LanguageNames.CSharp)]
public class CSharpCA1019DiagnosticAnalyzer : CA1019DiagnosticAnalyzer
{
......
......@@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers.Design
/// Cause:
/// A public or protected method has a name that starts with Get, takes no parameters, and returns a value that is not an array.
/// </summary>
[DiagnosticAnalyzer]
[DiagnosticAnalyzer(LanguageNames.CSharp)]
[ExportDiagnosticAnalyzer(LanguageNames.CSharp)]
public class CSharpCA1024DiagnosticAnalyzer : CA1024DiagnosticAnalyzer
{
......
......@@ -22,7 +22,7 @@ namespace Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers.Design
/// An externally visible enumeration is marked with FlagsAttribute and it has one or more values that are not powers of two or
/// a combination of the other defined values on the enumeration.
/// </summary>
[DiagnosticAnalyzer]
[DiagnosticAnalyzer(LanguageNames.CSharp)]
[ExportDiagnosticAnalyzer(LanguageNames.CSharp)]
public class CSharpEnumWithFlagsDiagnosticAnalyzer : EnumWithFlagsDiagnosticAnalyzer
{
......
......@@ -11,7 +11,7 @@
namespace Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers.Globalization
{
[DiagnosticAnalyzer]
[DiagnosticAnalyzer(LanguageNames.CSharp)]
[ExportDiagnosticAnalyzer(LanguageNames.CSharp)]
public class CSharpCA1309DiagnosticAnalyzer : CA1309DiagnosticAnalyzer
{
......
......@@ -8,7 +8,7 @@
namespace Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers.Performance
{
[DiagnosticAnalyzer]
[DiagnosticAnalyzer(LanguageNames.CSharp)]
[ExportDiagnosticAnalyzer(LanguageNames.CSharp)]
public class CSharpCA1821DiagnosticAnalyzer : CA1821DiagnosticAnalyzer
{
......
......@@ -20,7 +20,7 @@ namespace Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers.Reliability
/// A thread that tries to acquire a lock on an object that has a weak identity can be blocked by a second thread in
/// a different application domain that has a lock on the same object.
/// </summary>
[DiagnosticAnalyzer]
[DiagnosticAnalyzer(LanguageNames.CSharp)]
[ExportDiagnosticAnalyzer(LanguageNames.CSharp)]
public class CSharpCA2002DiagnosticAnalyzer : CA2002DiagnosticAnalyzer, ISyntaxNodeAnalyzer<SyntaxKind>
{
......
......@@ -9,7 +9,7 @@
namespace Microsoft.CodeAnalysis.FxCopAnalyzers.Usage
{
[DiagnosticAnalyzer]
[DiagnosticAnalyzer(LanguageNames.CSharp)]
[ExportDiagnosticAnalyzer(LanguageNames.CSharp)]
public class CSharpCA2200DiagnosticAnalyzer : CA2200DiagnosticAnalyzer, ISyntaxNodeAnalyzer<SyntaxKind>
{
......
......@@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers.Usage
/// <summary>
/// CA2213: Disposable fields should be disposed
/// </summary>
[DiagnosticAnalyzer]
[DiagnosticAnalyzer(LanguageNames.CSharp)]
[ExportDiagnosticAnalyzer(LanguageNames.CSharp)]
public class CSharpCA2213DiagnosticAnalyzer : CA2213DiagnosticAnalyzer
{
......
......@@ -19,7 +19,7 @@ namespace Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers.Usage
/// until run time. When a constructor calls a virtual method, it is possible that the constructor for the
/// instance that invokes the method has not executed.
/// </summary>
[DiagnosticAnalyzer]
[DiagnosticAnalyzer(LanguageNames.CSharp)]
[ExportDiagnosticAnalyzer(LanguageNames.CSharp)]
public class CSharpCA2214DiagnosticAnalyzer : CA2214DiagnosticAnalyzer
{
......
......@@ -13,7 +13,7 @@
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
</Dependencies>
<Assets>
<Asset Type="Microsoft.VisualStudio.MefComponent" Path="Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers.dll" />
<Asset Type="Microsoft.VisualStudio.MefComponent" Path="Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers.dll" />
<Asset Type="Microsoft.VisualStudio.Analyzer" Path="Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers.dll" />
<Asset Type="Microsoft.VisualStudio.Analyzer" Path="Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers.dll" />
</Assets>
</PackageManifest>
\ No newline at end of file
......@@ -4,7 +4,7 @@ Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.FxCopAnalyzers.Design
Namespace Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers.Design
<DiagnosticAnalyzer>
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
<ExportDiagnosticAnalyzer(LanguageNames.VisualBasic)>
Public Class BasicCA1003DiagnosticAnalyzer
Inherits CA1003DiagnosticAnalyzer
......
......@@ -4,7 +4,7 @@ Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.FxCopAnalyzers.Design
Namespace Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers.Design
<DiagnosticAnalyzer>
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
<ExportDiagnosticAnalyzer(LanguageNames.VisualBasic)>
Public Class BasicCA1019DiagnosticAnalyzer
Inherits CA1019DiagnosticAnalyzer
......
......@@ -7,7 +7,7 @@ Imports System.Collections.Immutable
Imports System.Threading
Namespace Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers.Design
<DiagnosticAnalyzer>
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
<ExportDiagnosticAnalyzer(LanguageNames.VisualBasic)>
Public Class BasicCA1024DiagnosticAnalyzer
Inherits CA1024DiagnosticAnalyzer
......
......@@ -9,7 +9,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers.Design
''' 1) CA1027: Mark enums with FlagsAttribute
''' 2) CA2217: Do not mark enums with FlagsAttribute
''' </summary>
<DiagnosticAnalyzer>
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
<ExportDiagnosticAnalyzer(LanguageNames.VisualBasic)>
Public NotInheritable Class BasicEnumWithFlagsDiagnosticAnalyzer
Inherits EnumWithFlagsDiagnosticAnalyzer
......
......@@ -8,7 +8,7 @@ Imports System.Collections.Immutable
Imports System.Threading
Namespace Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers.Globalization
<DiagnosticAnalyzer>
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
<ExportDiagnosticAnalyzer(LanguageNames.VisualBasic)>
Public Class BasicCA1309DiagnosticAnalyzer
Inherits CA1309DiagnosticAnalyzer
......
......@@ -6,7 +6,7 @@ Imports Microsoft.CodeAnalysis.FxCopAnalyzers.Utilities
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers.Performance
<DiagnosticAnalyzer>
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
<ExportDiagnosticAnalyzer(LanguageNames.VisualBasic)>
Public Class BasicCA1821DiagnosticAnalyzer
Inherits CA1821DiagnosticAnalyzer
......
......@@ -11,7 +11,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers.Usage
''' <summary>
''' CA2002: Do not lock on objects with weak identities
''' </summary>
<DiagnosticAnalyzer>
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
<ExportDiagnosticAnalyzer(LanguageNames.VisualBasic)>
Public Class BasicCA2002DiagnosticAnalyzer
Inherits CA2002DiagnosticAnalyzer
......
......@@ -7,7 +7,7 @@ Imports Microsoft.CodeAnalysis.FxCopAnalyzers.Usage
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers.Usage
<DiagnosticAnalyzer>
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
<ExportDiagnosticAnalyzer(LanguageNames.VisualBasic)>
Public Class BasicCA2200DiagnosticAnalyzer
Inherits CA2200DiagnosticAnalyzer
......
......@@ -7,7 +7,7 @@ Imports Microsoft.CodeAnalysis.FxCopAnalyzers.Usage
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers.Usage
<DiagnosticAnalyzer>
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
<ExportDiagnosticAnalyzer(LanguageNames.VisualBasic)>
Public Class BasicCA2213DiagnosticAnalyzer
Inherits CA2213DiagnosticAnalyzer
......
......@@ -8,7 +8,7 @@ Imports Microsoft.CodeAnalysis.FxCopAnalyzers.Utilities
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers.Usage
<DiagnosticAnalyzer>
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
<ExportDiagnosticAnalyzer(LanguageNames.VisualBasic)>
Public Class BasicCA2214DiagnosticAnalyzer
Inherits CA2214DiagnosticAnalyzer
......
......@@ -12,7 +12,7 @@
namespace Roslyn.Diagnostics.Analyzers.CSharp
{
[DiagnosticAnalyzer]
[DiagnosticAnalyzer(LanguageNames.CSharp)]
[ExportDiagnosticAnalyzer(LanguageNames.CSharp)]
public class CSharpSpecializedEnumerableCreationAnalyzer : SpecializedEnumerableCreationAnalyzer
{
......
......@@ -13,7 +13,7 @@
namespace Roslyn.Diagnostics.Analyzers.CSharp.Reliability
{
[DiagnosticAnalyzer]
[DiagnosticAnalyzer(LanguageNames.CSharp)]
[ExportDiagnosticAnalyzer(LanguageNames.CSharp)]
public sealed class CSharpDirectlyAwaitingTaskAnalyzer : DirectlyAwaitingTaskAnalyzer<SyntaxKind>
{
......
......@@ -8,7 +8,7 @@ Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Roslyn.Diagnostics.Analyzers.VisualBasic
<DiagnosticAnalyzer>
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
<ExportDiagnosticAnalyzer(LanguageNames.VisualBasic)>
Public Class BasicSpecializedEnumerableCreationAnalyzer
Inherits SpecializedEnumerableCreationAnalyzer
......
......@@ -9,7 +9,7 @@ Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Roslyn.Diagnostics.Analyzers.VisualBasic
<DiagnosticAnalyzer>
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
<ExportDiagnosticAnalyzer(LanguageNames.VisualBasic)>
Public Class BasicDirectlyAwaitingTaskAnalyzer
Inherits DirectlyAwaitingTaskAnalyzer(Of SyntaxKind)
......
......@@ -9,7 +9,7 @@ Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Roslyn.Diagnostics.Analyzers.VisualBasic
<DiagnosticAnalyzer>
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
<ExportDiagnosticAnalyzer(LanguageNames.VisualBasic)>
Public Class BasicUseSiteDiagnosticsCheckEnforcerAnalyzer
Inherits AbstractCodeBlockAnalyzerFactory(Of SyntaxKind)
......
......@@ -51,7 +51,7 @@ public object GetOption(OptionKey optionKey)
if (!values.TryGetValue(optionKey, out value))
{
value = this.service.GetOption(optionKey);
value = this.service != null ? this.service.GetOption(optionKey) : optionKey.Option.DefaultValue;
values = values.Add(optionKey, value);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册