提交 839b808b 编写于 作者: C CyrusNajmabadi

Merge branch 'dev15-rc' into portFix1

......@@ -27,6 +27,11 @@ function Run-Build()
$debugDir = join-path $rootDir "Binaries\Debug"
$objDir = join-path $rootDir "Binaries\Obj"
# Temporarily forcing MSBuild 14.0 here to work around a bug in 15.0
# MSBuild bug: https://github.com/Microsoft/msbuild/issues/1183
# Roslyn tracking bug: https://github.com/dotnet/roslyn/issues/14451
$msbuild = "c:\Program Files (x86)\MSBuild\14.0\bin\MSBuild.exe"
# Create directories that may or may not exist to make the script execution below
# clean in either case.
mkdir $debugDir -errorAction SilentlyContinue | out-null
......@@ -38,10 +43,10 @@ function Run-Build()
write-host "Cleaning the Binaries"
rm -re -fo $debugDir
rm -re -fo $objDir
& msbuild /nologo /v:m /nodeReuse:false /t:clean $sln
& $msbuild /nologo /v:m /nodeReuse:false /t:clean $sln
write-host "Building the Solution"
& msbuild /nologo /v:m /nodeReuse:false /m /p:DebugDeterminism=true /p:BootstrapBuildPath=$script:buildDir '/p:Features="debug-determinism;pdb-path-determinism"' /p:UseRoslynAnalyzers=false $pathMapBuildOption $sln
& $msbuild /nologo /v:m /nodeReuse:false /m /p:DebugDeterminism=true /p:BootstrapBuildPath=$script:buildDir '/p:Features="debug-determinism;pdb-path-determinism"' /p:UseRoslynAnalyzers=false $pathMapBuildOption $sln
popd
}
......
......@@ -152,7 +152,7 @@ set TMP=%TEMP%
}
}
def triggerPhraseOnly = true
def triggerPhraseOnly = false
def triggerPhraseExtra = "determinism"
Utilities.setMachineAffinity(myJob, 'Windows_NT', 'latest-or-auto-dev15')
addRoslynJob(myJob, jobName, branchName, isPr, triggerPhraseExtra, triggerPhraseOnly)
......
......@@ -1655,5 +1655,233 @@ public partial class C33 { }
Diagnostic("UniqueTextFileDiagnostic").WithArguments("Source3_File5.designer.cs").WithLocation(1, 1),
Diagnostic("NumberOfUniqueTextFileDescriptor").WithArguments("3").WithLocation(1, 1));
}
[Fact, WorkItem(8753, "https://github.com/dotnet/roslyn/issues/8753")]
public void TestParametersAnalyzer_InConstructor()
{
string source = @"
public class C
{
public C(int a, int b)
{
}
}
";
var tree = CSharpSyntaxTree.ParseText(source, path: "Source.cs");
var compilation = CreateCompilationWithMscorlib45(new[] { tree });
compilation.VerifyDiagnostics();
var analyzers = new DiagnosticAnalyzer[] { new AnalyzerForParameters() };
compilation.VerifyAnalyzerDiagnostics(analyzers, null, null, true,
Diagnostic("Parameter_ID", "a").WithLocation(4, 18),
Diagnostic("Parameter_ID", "b").WithLocation(4, 25));
}
[Fact, WorkItem(8753, "https://github.com/dotnet/roslyn/issues/8753")]
public void TestParametersAnalyzer_InRegularMethod()
{
string source = @"
public class C
{
void M1(string a, string b)
{
}
}
";
var tree = CSharpSyntaxTree.ParseText(source, path: "Source.cs");
var compilation = CreateCompilationWithMscorlib45(new[] { tree });
compilation.VerifyDiagnostics();
var analyzers = new DiagnosticAnalyzer[] { new AnalyzerForParameters() };
compilation.VerifyAnalyzerDiagnostics(analyzers, null, null, true,
Diagnostic("Parameter_ID", "a").WithLocation(4, 20),
Diagnostic("Parameter_ID", "b").WithLocation(4, 30));
}
[Fact, WorkItem(8753, "https://github.com/dotnet/roslyn/issues/8753")]
public void TestParametersAnalyzer_InIndexers()
{
string source = @"
public class C
{
public int this[int index]
{
get { return 0; }
set { }
}
}
";
var tree = CSharpSyntaxTree.ParseText(source, path: "Source.cs");
var compilation = CreateCompilationWithMscorlib45(new[] { tree });
compilation.VerifyDiagnostics();
var analyzers = new DiagnosticAnalyzer[] { new AnalyzerForParameters() };
compilation.VerifyAnalyzerDiagnostics(analyzers, null, null, true,
Diagnostic("Parameter_ID", "index").WithLocation(4, 25));
}
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/14061"), WorkItem(8753, "https://github.com/dotnet/roslyn/issues/8753")]
public void TestParametersAnalyzer_Lambdas()
{
string source = @"
public class C
{
void M2()
{
System.Func<int, int, int> x = (int a, int b) => b;
}
}
";
var tree = CSharpSyntaxTree.ParseText(source, path: "Source.cs");
var compilation = CreateCompilationWithMscorlib45(new[] { tree });
compilation.VerifyDiagnostics();
var analyzers = new DiagnosticAnalyzer[] { new AnalyzerForParameters() };
compilation.VerifyAnalyzerDiagnostics(analyzers, null, null, true,
Diagnostic("Local_ID", "x").WithLocation(6, 36),
Diagnostic("Parameter_ID", "a").WithLocation(6, 45),
Diagnostic("Parameter_ID", "b").WithLocation(6, 52));
}
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/14061"), WorkItem(8753, "https://github.com/dotnet/roslyn/issues/8753")]
public void TestParametersAnalyzer_InAnonymousMethods()
{
string source = @"
public class C
{
void M3()
{
M4(delegate (int x, int y) { });
}
void M4(System.Action<int, int> a) { }
}
";
var tree = CSharpSyntaxTree.ParseText(source, path: "Source.cs");
var compilation = CreateCompilationWithMscorlib45(new[] { tree });
compilation.VerifyDiagnostics();
var analyzers = new DiagnosticAnalyzer[] { new AnalyzerForParameters() };
compilation.VerifyAnalyzerDiagnostics(analyzers, null, null, true,
Diagnostic("Parameter_ID", "a").WithLocation(9, 37),
Diagnostic("Parameter_ID", "x").WithLocation(6, 26),
Diagnostic("Parameter_ID", "y").WithLocation(6, 33));
}
[Fact, WorkItem(8753, "https://github.com/dotnet/roslyn/issues/8753")]
public void TestParametersAnalyzer_InDelegateTypes()
{
string source = @"
public class C
{
delegate void D(int x, string y);
}
";
var tree = CSharpSyntaxTree.ParseText(source, path: "Source.cs");
var compilation = CreateCompilationWithMscorlib45(new[] { tree });
compilation.VerifyDiagnostics();
var analyzers = new DiagnosticAnalyzer[] { new AnalyzerForParameters() };
compilation.VerifyAnalyzerDiagnostics(analyzers, null, null, true,
Diagnostic("Parameter_ID", "x").WithLocation(4, 25),
Diagnostic("Parameter_ID", "y").WithLocation(4, 35));
}
[Fact, WorkItem(8753, "https://github.com/dotnet/roslyn/issues/8753")]
public void TestParametersAnalyzer_InOperators()
{
string source = @"
public class C
{
public static implicit operator int (C c) { return 0; }
}
";
var tree = CSharpSyntaxTree.ParseText(source, path: "Source.cs");
var compilation = CreateCompilationWithMscorlib45(new[] { tree });
compilation.VerifyDiagnostics();
var analyzers = new DiagnosticAnalyzer[] { new AnalyzerForParameters() };
compilation.VerifyAnalyzerDiagnostics(analyzers, null, null, true,
Diagnostic("Parameter_ID", "c").WithLocation(4, 44));
}
[Fact, WorkItem(8753, "https://github.com/dotnet/roslyn/issues/8753")]
public void TestParametersAnalyzer_InExplicitInterfaceImplementations()
{
string source = @"
interface I
{
void M(int a, int b);
}
public class C : I
{
void I.M(int c, int d) { }
}
";
var tree = CSharpSyntaxTree.ParseText(source, path: "Source.cs");
var compilation = CreateCompilationWithMscorlib45(new[] { tree });
compilation.VerifyDiagnostics();
var analyzers = new DiagnosticAnalyzer[] { new AnalyzerForParameters() };
compilation.VerifyAnalyzerDiagnostics(analyzers, null, null, true,
Diagnostic("Parameter_ID", "c").WithLocation(9, 18),
Diagnostic("Parameter_ID", "d").WithLocation(9, 25),
Diagnostic("Parameter_ID", "a").WithLocation(4, 16),
Diagnostic("Parameter_ID", "b").WithLocation(4, 23));
}
[Fact, WorkItem(8753, "https://github.com/dotnet/roslyn/issues/8753")]
public void TestParametersAnalyzer_InExtensionMethods()
{
string source = @"
public static class C
{
static void M(this int x, int y) { }
}
";
var tree = CSharpSyntaxTree.ParseText(source, path: "Source.cs");
var compilation = CreateCompilationWithMscorlib45(new[] { tree });
compilation.VerifyDiagnostics();
var analyzers = new DiagnosticAnalyzer[] { new AnalyzerForParameters() };
compilation.VerifyAnalyzerDiagnostics(analyzers, null, null, true,
Diagnostic("Parameter_ID", "x").WithLocation(4, 28),
Diagnostic("Parameter_ID", "y").WithLocation(4, 35));
}
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/14061"), WorkItem(8753, "https://github.com/dotnet/roslyn/issues/8753")]
public void TestParametersAnalyzer_InLocalFunctions()
{
string source = @"
public class C
{
void M1()
{
M2(1, 2);
void M2(int a, int b)
{
}
}
}
";
var tree = CSharpSyntaxTree.ParseText(source, path: "Source.cs");
var compilation = CreateCompilationWithMscorlib45(new[] { tree });
compilation.VerifyDiagnostics();
var analyzers = new DiagnosticAnalyzer[] { new AnalyzerForParameters() };
compilation.VerifyAnalyzerDiagnostics(analyzers, null, null, true,
Diagnostic("Parameter_ID", "a").WithLocation(4, 18), // ctor
Diagnostic("Parameter_ID", "b").WithLocation(4, 25),
Diagnostic("Local_ID", "c").WithLocation(6, 13),
Diagnostic("Local_ID", "d").WithLocation(6, 20),
Diagnostic("Parameter_ID", "a").WithLocation(10, 20), // M1
Diagnostic("Parameter_ID", "b").WithLocation(10, 30),
Diagnostic("Local_ID", "c").WithLocation(12, 11),
Diagnostic("Local_ID", "x").WithLocation(18, 36), // M2
Diagnostic("Parameter_ID", "a").WithLocation(26, 37), // M4
Diagnostic("Parameter_ID", "index").WithLocation(28, 25)); // indexer
}
}
}
......@@ -701,6 +701,8 @@ public struct SymbolAnalysisContext
/// </summary>
public CancellationToken CancellationToken { get { return _cancellationToken; } }
internal Func<Diagnostic, bool> IsSupportedDiagnostic => _isSupportedDiagnostic;
public SymbolAnalysisContext(ISymbol symbol, Compilation compilation, AnalyzerOptions options, Action<Diagnostic> reportDiagnostic, Func<Diagnostic, bool> isSupportedDiagnostic, CancellationToken cancellationToken)
{
_symbol = symbol;
......
......@@ -608,6 +608,53 @@ public void RegisterSymbolAction(DiagnosticAnalyzer analyzer, Action<SymbolAnaly
SymbolAnalyzerAction analyzerAction = new SymbolAnalyzerAction(action, symbolKinds, analyzer);
this.GetOrCreateAnalyzerActions(analyzer).AddSymbolAction(analyzerAction);
_symbolActions = _symbolActions.Add(analyzerAction);
// The SymbolAnalyzerAction does not handle SymbolKind.Parameter because the compiler
// does not make CompilationEvents for them. As a workaround, handle them specially by
// registering further SymbolActions (for Methods) and utilize the results to construct
// the necessary SymbolAnalysisContexts.
if (symbolKinds.Contains(SymbolKind.Parameter))
{
RegisterSymbolAction(
analyzer,
context =>
{
ImmutableArray<IParameterSymbol> parameters;
switch (context.Symbol.Kind)
{
case SymbolKind.Method:
parameters = ((IMethodSymbol)context.Symbol).Parameters;
break;
case SymbolKind.Property:
parameters = ((IPropertySymbol)context.Symbol).Parameters;
break;
case SymbolKind.NamedType:
var namedType = (INamedTypeSymbol)context.Symbol;
var delegateInvokeMethod = namedType.DelegateInvokeMethod;
parameters = delegateInvokeMethod?.Parameters ?? ImmutableArray.Create<IParameterSymbol>();
break;
default:
throw new ArgumentException(nameof(context));
}
foreach (var parameter in parameters)
{
if (!parameter.IsImplicitlyDeclared)
{
action(new SymbolAnalysisContext(
parameter,
context.Compilation,
context.Options,
context.ReportDiagnostic,
context.IsSupportedDiagnostic,
context.CancellationToken));
}
}
},
ImmutableArray.Create(SymbolKind.Method, SymbolKind.Property, SymbolKind.NamedType));
}
}
public void RegisterCodeBlockStartAction<TLanguageKindEnum>(DiagnosticAnalyzer analyzer, Action<CodeBlockStartAnalysisContext<TLanguageKindEnum>> action) where TLanguageKindEnum : struct
......
......@@ -981,6 +981,162 @@ End Class
Diagnostic(OwningSymbolTestAnalyzer.ExpressionDescriptor.Id, "12").WithLocation(12, 36))
End Sub
<Fact, WorkItem(8753, "https://github.com/dotnet/roslyn/issues/8753")>
Public Sub TestParametersAnalyzer_InRegularMethods()
Dim source = <compilation>
<file name="c.vb">
<![CDATA[
Class C
Public Sub M(a As Integer, b As String)
End Sub
End Class
]]>
</file>
</compilation>
Dim comp = CreateCompilationWithMscorlibAndVBRuntime(source)
comp.VerifyDiagnostics()
comp.VerifyAnalyzerDiagnostics({New AnalyzerForParameters}, Nothing, Nothing, False,
Diagnostic("Parameter_ID", "a").WithLocation(2, 18),
Diagnostic("Parameter_ID", "b").WithLocation(2, 32))
End Sub
<Fact, WorkItem(8753, "https://github.com/dotnet/roslyn/issues/8753")>
Public Sub TestParametersAnalyzer_InConstructors()
Dim source = <compilation>
<file name="c.vb">
<![CDATA[
Class C
Public Sub New(a As Integer, b As String)
End Sub
End Class
]]>
</file>
</compilation>
Dim comp = CreateCompilationWithMscorlibAndVBRuntime(source)
comp.VerifyDiagnostics()
comp.VerifyAnalyzerDiagnostics({New AnalyzerForParameters}, Nothing, Nothing, False,
Diagnostic("Parameter_ID", "a").WithLocation(2, 20),
Diagnostic("Parameter_ID", "b").WithLocation(2, 34))
End Sub
<Fact, WorkItem(8753, "https://github.com/dotnet/roslyn/issues/8753")>
Public Sub TestParametersAnalyzer_InIndexers()
Dim source = <compilation>
<file name="c.vb">
<![CDATA[
Class C
Default Public Property Item(a As Integer, b As Integer) As Integer
Get
Return 0
End Get
Set(ByVal Value As Integer)
End Set
End Property
End Class
]]>
</file>
</compilation>
Dim comp = CreateCompilationWithMscorlibAndVBRuntime(source)
comp.VerifyDiagnostics()
comp.VerifyAnalyzerDiagnostics({New AnalyzerForParameters}, Nothing, Nothing, False,
Diagnostic("Parameter_ID", "a").WithLocation(2, 34),
Diagnostic("Parameter_ID", "b").WithLocation(2, 48),
Diagnostic("Parameter_ID", "Value").WithLocation(6, 19))
End Sub
<Fact(Skip:="https://github.com/dotnet/roslyn/issues/14062"), WorkItem(8753, "https://github.com/dotnet/roslyn/issues/8753")>
Public Sub TestParametersAnalyzer_InDelegateTypes()
Dim source = <compilation>
<file name="c.vb">
<![CDATA[
Class C
Delegate Sub DelegateType(a As Integer, b As String)
End Class
]]>
</file>
</compilation>
Dim comp = CreateCompilationWithMscorlibAndVBRuntime(source)
comp.VerifyDiagnostics()
comp.VerifyAnalyzerDiagnostics({New AnalyzerForParameters}, Nothing, Nothing, False,
Diagnostic("Parameter_ID", "a").WithLocation(2, 34),
Diagnostic("Parameter_ID", "b").WithLocation(2, 48))
End Sub
<Fact, WorkItem(8753, "https://github.com/dotnet/roslyn/issues/8753")>
Public Sub TestParametersAnalyzer_InOperators()
Dim source = <compilation>
<file name="c.vb">
<![CDATA[
Class C
Public Shared Operator +(ByVal h1 As C, ByVal h2 As C)
Return New C()
End Operator
End Class
]]>
</file>
</compilation>
Dim comp = CreateCompilationWithMscorlibAndVBRuntime(source)
comp.VerifyDiagnostics()
comp.VerifyAnalyzerDiagnostics({New AnalyzerForParameters}, Nothing, Nothing, False,
Diagnostic("Parameter_ID", "h1").WithLocation(2, 36),
Diagnostic("Parameter_ID", "h2").WithLocation(2, 51))
End Sub
<Fact, WorkItem(8753, "https://github.com/dotnet/roslyn/issues/8753")>
Public Sub TestParametersAnalyzer_InInterfaceImplementations()
Dim source = <compilation>
<file name="c.vb">
<![CDATA[
Interface I
Sub M(a As Integer, b As String)
End Interface
Class C
Implements I
Public Sub M(a As Integer, b As String) Implements I.M
End Sub
End Class
]]>
</file>
</compilation>
Dim comp = CreateCompilationWithMscorlibAndVBRuntime(source)
comp.VerifyDiagnostics()
comp.VerifyAnalyzerDiagnostics({New AnalyzerForParameters}, Nothing, Nothing, False,
Diagnostic("Parameter_ID", "a").WithLocation(2, 11),
Diagnostic("Parameter_ID", "b").WithLocation(2, 25),
Diagnostic("Parameter_ID", "a").WithLocation(7, 18),
Diagnostic("Parameter_ID", "b").WithLocation(7, 32))
End Sub
<Fact, WorkItem(8753, "https://github.com/dotnet/roslyn/issues/8753")>
Public Sub TestParametersAnalyzer_InParameterizedProperties()
Dim source = <compilation>
<file name="c.vb">
<![CDATA[
Class C
Public ReadOnly Property Test(a As Integer, b As String) As Integer
Get
Return 1
End Get
End Property
End Class
]]>
</file>
</compilation>
Dim comp = CreateCompilationWithMscorlibAndVBRuntime(source)
comp.VerifyDiagnostics()
comp.VerifyAnalyzerDiagnostics({New AnalyzerForParameters}, Nothing, Nothing, False,
Diagnostic("Parameter_ID", "a").WithLocation(2, 35),
Diagnostic("Parameter_ID", "b").WithLocation(2, 49))
End Sub
Private Shared Sub VerifyGeneratedCodeAnalyzerDiagnostics(compilation As Compilation, isGeneratedFileName As Func(Of String, Boolean), generatedCodeAnalysisFlagsOpt As GeneratedCodeAnalysisFlags?)
Dim expected = GetExpectedGeneratedCodeAnalyzerDiagnostics(compilation, isGeneratedFileName, generatedCodeAnalysisFlagsOpt)
VerifyGeneratedCodeAnalyzerDiagnostics(compilation, expected, generatedCodeAnalysisFlagsOpt)
......
// Copyright (c) Microsoft. 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.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
......@@ -131,13 +132,27 @@ internal partial class Session
var filterResults = new List<FilterResult>();
var filterText = model.GetCurrentTextInSnapshot(model.OriginalList.Span, textSnapshot, textSpanToText);
var filterText = model.GetCurrentTextInSnapshot(
model.OriginalList.Span, textSnapshot, textSpanToText);
// If the user was typing a number, then immediately dismiss completion.
// Check if the user is typing a number. If so, only proceed if it's a number
// directly after a <dot>. That's because it is actually reasonable for completion
// to be brought up after a <dot> and for the user to want to filter completion
// items based on a number that exists in the name of the item. However, when
// we are not after a dot (i.e. we're being brought up after <space> is typed)
// then we don't want to filter things. Consider the user writing:
//
// dim i =<space>
//
// We'll bring up the completion list here (as VB has completion on <space>).
// If the user then types '3', we don't want to match against Int32.
var filterTextStartsWithANumber = filterText.Length > 0 && char.IsNumber(filterText[0]);
if (filterTextStartsWithANumber)
{
return null;
if (!IsAfterDot(model, textSnapshot, textSpanToText))
{
return null;
}
}
foreach (var currentItem in model.TotalItems)
......@@ -196,6 +211,17 @@ internal partial class Session
helper, recentItems, filterText, filterResults);
}
private Boolean IsAfterDot(Model model, ITextSnapshot textSnapshot, Dictionary<TextSpan, string> textSpanToText)
{
var span = model.OriginalList.Span;
// Move the span back one character if possible.
span = TextSpan.FromBounds(Math.Max(0, span.Start - 1), span.End);
var text = model.GetCurrentTextInSnapshot(span, textSnapshot, textSpanToText);
return text.Length > 0 && text[0] == '.';
}
private Model HandleNormalFiltering(
Model model,
Document document,
......@@ -424,13 +450,6 @@ public FilterResult(PresentationItem presentationItem, string filterText, bool m
}
}
if (filterText.Length > 0 && IsAllDigits(filterText))
{
// The user is just typing a number. We never want this to match against
// anything we would put in a completion list.
return false;
}
return helper.MatchesFilterText(item, filterText, CultureInfo.CurrentCulture);
}
......
......@@ -2244,5 +2244,26 @@ class Program
Await state.AssertSelectedCompletionItem("DateTime")
End Using
End Function
<WorkItem(14465, "https://github.com/dotnet/roslyn/issues/14465")>
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function TypingNumberShouldNotDismiss1() As Task
Using state = TestState.CreateCSharpTestState(
<Document><![CDATA[
class C
{
void Moo1()
{
new C()$$
}
}
]]></Document>)
state.SendTypeChars(".")
Await state.AssertCompletionSession()
state.SendTypeChars("1")
Await state.AssertSelectedCompletionItem("Moo1")
End Using
End Function
End Class
End Namespace
\ No newline at end of file
......@@ -47,6 +47,8 @@ public bool Matches(CompletionItem item)
public static readonly CompletionItemFilter MethodFilter = new CompletionItemFilter(FeaturesResources.Methods, CompletionTags.Method, 'm');
public static readonly CompletionItemFilter ExtensionMethodFilter = new CompletionItemFilter(FeaturesResources.Extension_methods, CompletionTags.ExtensionMethod, 'x');
public static readonly CompletionItemFilter LocalAndParameterFilter = new CompletionItemFilter(FeaturesResources.Locals_and_parameters, ImmutableArray.Create(CompletionTags.Local, CompletionTags.Parameter), 'l');
public static readonly CompletionItemFilter KeywordFilter = new CompletionItemFilter(FeaturesResources.Keywords, ImmutableArray.Create(CompletionTags.Keyword), 'k');
public static readonly CompletionItemFilter SnippetFilter = new CompletionItemFilter(FeaturesResources.Snippets, ImmutableArray.Create(CompletionTags.Snippet), 't');
public static readonly ImmutableArray<CompletionItemFilter> NamespaceFilters = ImmutableArray.Create(NamespaceFilter);
public static readonly ImmutableArray<CompletionItemFilter> ClassFilters = ImmutableArray.Create(ClassFilter);
......@@ -62,6 +64,8 @@ public bool Matches(CompletionItem item)
public static readonly ImmutableArray<CompletionItemFilter> MethodFilters = ImmutableArray.Create(MethodFilter);
public static readonly ImmutableArray<CompletionItemFilter> ExtensionMethodFilters = ImmutableArray.Create(ExtensionMethodFilter);
public static readonly ImmutableArray<CompletionItemFilter> LocalAndParameterFilters = ImmutableArray.Create(LocalAndParameterFilter);
public static readonly ImmutableArray<CompletionItemFilter> KeywordFilters = ImmutableArray.Create(KeywordFilter);
public static readonly ImmutableArray<CompletionItemFilter> SnippetFilters = ImmutableArray.Create(SnippetFilter);
public static ImmutableArray<CompletionItemFilter> AllFilters { get; } =
ImmutableArray.Create(
......@@ -78,6 +82,8 @@ public bool Matches(CompletionItem item)
StructureFilter,
EnumFilter,
DelegateFilter,
NamespaceFilter);
NamespaceFilter,
KeywordFilter,
SnippetFilter);
}
}
}
\ No newline at end of file
......@@ -1062,6 +1062,15 @@ internal class FeaturesResources {
}
}
/// <summary>
/// Looks up a localized string similar to Fully qualify &apos;{0}&apos;.
/// </summary>
internal static string Fully_qualify_0 {
get {
return ResourceManager.GetString("Fully_qualify_0", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Fully qualify name.
/// </summary>
......@@ -1602,6 +1611,15 @@ internal class FeaturesResources {
}
}
/// <summary>
/// Looks up a localized string similar to Keywords.
/// </summary>
internal static string Keywords {
get {
return ResourceManager.GetString("Keywords", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to label.
/// </summary>
......@@ -2166,6 +2184,15 @@ internal class FeaturesResources {
}
}
/// <summary>
/// Looks up a localized string similar to Remove reference to &apos;{0}&apos;..
/// </summary>
internal static string Remove_reference_to_0 {
get {
return ResourceManager.GetString("Remove_reference_to_0", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Remove Suppression.
/// </summary>
......@@ -2376,6 +2403,15 @@ internal class FeaturesResources {
}
}
/// <summary>
/// Looks up a localized string similar to Snippets.
/// </summary>
internal static string Snippets {
get {
return ResourceManager.GetString("Snippets", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Solution.
/// </summary>
......@@ -2403,6 +2439,15 @@ internal class FeaturesResources {
}
}
/// <summary>
/// Looks up a localized string similar to Spell check &apos;{0}&apos;.
/// </summary>
internal static string Spell_check_0 {
get {
return ResourceManager.GetString("Spell_check_0", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Structures.
/// </summary>
......@@ -2911,6 +2956,114 @@ internal class FeaturesResources {
}
}
/// <summary>
/// Looks up a localized string similar to Use block body for accessors.
/// </summary>
internal static string Use_block_body_for_accessors {
get {
return ResourceManager.GetString("Use_block_body_for_accessors", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Use block body for constructors.
/// </summary>
internal static string Use_block_body_for_constructors {
get {
return ResourceManager.GetString("Use_block_body_for_constructors", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Use block body for indexers.
/// </summary>
internal static string Use_block_body_for_indexers {
get {
return ResourceManager.GetString("Use_block_body_for_indexers", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Use block body for methods.
/// </summary>
internal static string Use_block_body_for_methods {
get {
return ResourceManager.GetString("Use_block_body_for_methods", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Use block body for operators.
/// </summary>
internal static string Use_block_body_for_operators {
get {
return ResourceManager.GetString("Use_block_body_for_operators", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Use block body for properties.
/// </summary>
internal static string Use_block_body_for_properties {
get {
return ResourceManager.GetString("Use_block_body_for_properties", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Use expression body for accessors.
/// </summary>
internal static string Use_expression_body_for_accessors {
get {
return ResourceManager.GetString("Use_expression_body_for_accessors", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Use expression body for constructors.
/// </summary>
internal static string Use_expression_body_for_constructors {
get {
return ResourceManager.GetString("Use_expression_body_for_constructors", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Use expression body for indexers.
/// </summary>
internal static string Use_expression_body_for_indexers {
get {
return ResourceManager.GetString("Use_expression_body_for_indexers", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Use expression body for methods.
/// </summary>
internal static string Use_expression_body_for_methods {
get {
return ResourceManager.GetString("Use_expression_body_for_methods", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Use expression body for operators.
/// </summary>
internal static string Use_expression_body_for_operators {
get {
return ResourceManager.GetString("Use_expression_body_for_operators", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Use expression body for properties.
/// </summary>
internal static string Use_expression_body_for_properties {
get {
return ResourceManager.GetString("Use_expression_body_for_properties", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Use framework type.
/// </summary>
......
......@@ -1088,4 +1088,55 @@ This version used in: {2}</value>
<data name="Fully_qualify_name" xml:space="preserve">
<value>Fully qualify name</value>
</data>
<data name="Use_expression_body_for_methods" xml:space="preserve">
<value>Use expression body for methods</value>
</data>
<data name="Use_block_body_for_methods" xml:space="preserve">
<value>Use block body for methods</value>
</data>
<data name="Use_block_body_for_accessors" xml:space="preserve">
<value>Use block body for accessors</value>
</data>
<data name="Use_block_body_for_constructors" xml:space="preserve">
<value>Use block body for constructors</value>
</data>
<data name="Use_block_body_for_indexers" xml:space="preserve">
<value>Use block body for indexers</value>
</data>
<data name="Use_block_body_for_operators" xml:space="preserve">
<value>Use block body for operators</value>
</data>
<data name="Use_block_body_for_properties" xml:space="preserve">
<value>Use block body for properties</value>
</data>
<data name="Use_expression_body_for_accessors" xml:space="preserve">
<value>Use expression body for accessors</value>
</data>
<data name="Use_expression_body_for_constructors" xml:space="preserve">
<value>Use expression body for constructors</value>
</data>
<data name="Use_expression_body_for_indexers" xml:space="preserve">
<value>Use expression body for indexers</value>
</data>
<data name="Use_expression_body_for_operators" xml:space="preserve">
<value>Use expression body for operators</value>
</data>
<data name="Use_expression_body_for_properties" xml:space="preserve">
<value>Use expression body for properties</value>
</data>
<data name="Spell_check_0" xml:space="preserve">
<value>Spell check '{0}'</value>
</data>
<data name="Fully_qualify_0" xml:space="preserve">
<value>Fully qualify '{0}'</value>
</data>
<data name="Remove_reference_to_0" xml:space="preserve">
<value>Remove reference to '{0}'.</value>
</data>
<data name="Keywords" xml:space="preserve">
<value>Keywords</value>
</data>
<data name="Snippets" xml:space="preserve">
<value>Snippets</value>
</data>
</root>
\ No newline at end of file
......@@ -1067,5 +1067,29 @@ private void OnCompilationStart(CompilationStartAnalysisContext context)
});
}
}
[DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)]
public class AnalyzerForParameters : DiagnosticAnalyzer
{
public static readonly DiagnosticDescriptor ParameterDescriptor = new DiagnosticDescriptor(
"Parameter_ID",
"Parameter_Title",
"Parameter_Message",
"Parameter_Category",
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true);
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(ParameterDescriptor);
public override void Initialize(AnalysisContext context)
{
context.RegisterSymbolAction(SymbolAction, SymbolKind.Parameter);
}
private void SymbolAction(SymbolAnalysisContext context)
{
context.ReportDiagnostic(Diagnostic.Create(ParameterDescriptor, context.Symbol.Locations[0]));
}
}
}
}
\ No newline at end of file
......@@ -75,7 +75,11 @@ public void VerifyAllAnalyzerMembersWereCalled()
public void VerifyAnalyzeSymbolCalledForAllSymbolKinds()
{
var expectedSymbolKinds = new[] { SymbolKind.Event, SymbolKind.Field, SymbolKind.Method, SymbolKind.NamedType, SymbolKind.Namespace, SymbolKind.Property };
var expectedSymbolKinds = new[]
{
SymbolKind.Event, SymbolKind.Field, SymbolKind.Method, SymbolKind.NamedType, SymbolKind.Namespace, SymbolKind.Parameter, SymbolKind.Property
};
var actualSymbolKinds = _callLog.Where(a => FilterByAbstractName(a, "Symbol")).Where(e => e.SymbolKind.HasValue).Select(e => e.SymbolKind.Value).Distinct();
AssertSequenceEqual(expectedSymbolKinds, actualSymbolKinds);
}
......
......@@ -80,7 +80,7 @@ internal class OutOfProcDiagnosticAnalyzerExecutor : IRemoteHostDiagnosticAnalyz
}
var optionAsset = GetOptionsAsset(solution, project.Language, cancellationToken);
var hostChecksums = GetHostAnalyzerReferences(snapshotService, _analyzerService.GetHostAnalyzerReferences(), cancellationToken);
var hostChecksums = GetHostAnalyzerReferences(snapshotService, project.Language, _analyzerService.GetHostAnalyzerReferences(), cancellationToken);
var argument = new DiagnosticArguments(
analyzerDriver.AnalysisOptions.ReportSuppressedDiagnostics,
......@@ -160,12 +160,22 @@ private void ReportAnalyzerExceptions(Project project, ImmutableDictionary<Diagn
}
}
private ImmutableArray<byte[]> GetHostAnalyzerReferences(ISolutionSynchronizationService snapshotService, IEnumerable<AnalyzerReference> references, CancellationToken cancellationToken)
private ImmutableArray<byte[]> GetHostAnalyzerReferences(
ISolutionSynchronizationService snapshotService, string language, IEnumerable<AnalyzerReference> references, CancellationToken cancellationToken)
{
// TODO: cache this to somewhere
var builder = ImmutableArray.CreateBuilder<byte[]>();
foreach (var reference in references)
{
var analyzers = reference.GetAnalyzers(language);
if (analyzers.Length == 0)
{
// skip reference that doesn't contain any analyzers for the given language
// we do this so that we don't load analyzer dlls that MEF exported from vsix
// not related to this solution
continue;
}
var asset = snapshotService.GetGlobalAsset(reference, cancellationToken);
builder.Add(asset.Checksum.ToArray());
}
......
......@@ -3,6 +3,8 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Serialization;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.Execution
......@@ -48,4 +50,47 @@ private static Checksum CreateChecksumFromStreamWriter(string kind, Action<Objec
}
}
}
/// <summary>
/// workspace analyzer specific asset.
///
/// we need this to prevent dlls from other languages such as typescript, f#, xaml and etc
/// from loading at OOP start up.
///
/// unlike project analyzer, analyzer that got installed from vsix doesn't do shadow copying
/// so we don't need to load assembly to find out actual filepath.
///
/// this also will be temporary solution for RC since we will move to MVID for checksum soon
/// </summary>
internal sealed class WorkspaceAnalyzerReferenceAsset : CustomAsset
{
private readonly AnalyzerReference _reference;
private readonly Serializer _serializer;
public WorkspaceAnalyzerReferenceAsset(AnalyzerReference reference, Serializer serializer) :
base(CreateChecksum(reference), WellKnownSynchronizationKinds.AnalyzerReference)
{
_reference = reference;
_serializer = serializer;
}
public override Task WriteObjectToAsync(ObjectWriter writer, CancellationToken cancellationToken)
{
_serializer.SerializeAnalyzerReference(_reference, writer, cancellationToken);
return SpecializedTasks.EmptyTask;
}
private static Checksum CreateChecksum(AnalyzerReference reference)
{
using (var stream = SerializableBytes.CreateWritableStream())
using (var objectWriter = new ObjectWriter(stream))
{
objectWriter.WriteString(WellKnownSynchronizationKinds.AnalyzerReference);
objectWriter.WriteString(reference.FullPath);
return Checksum.Create(stream);
}
}
}
}
......@@ -23,16 +23,14 @@ public CustomAsset Build(OptionSet options, string language, CancellationToken c
{
cancellationToken.ThrowIfCancellationRequested();
return new SimpleCustomAsset(WellKnownSynchronizationKinds.OptionSet,
(writer, cancellationTokenOnStreamWriting) =>
return new SimpleCustomAsset(WellKnownSynchronizationKinds.OptionSet,
(writer, cancellationTokenOnStreamWriting) =>
_serializer.SerializeOptionSet(options, language, writer, cancellationTokenOnStreamWriting));
}
public CustomAsset Build(AnalyzerReference reference, CancellationToken cancellationToken)
{
return new SimpleCustomAsset(WellKnownSynchronizationKinds.AnalyzerReference,
(writer, cancellationTokenOnStreamWriting) =>
_serializer.SerializeAnalyzerReference(reference, writer, cancellationTokenOnStreamWriting));
return new WorkspaceAnalyzerReferenceAsset(reference, _serializer);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册