未验证 提交 e606428d 编写于 作者: J Julien Couvreur 提交者: GitHub

Adopt latest roslyn analyzers (#40839)

上级 31c2a014
...@@ -205,3 +205,6 @@ csharp_space_between_square_brackets = false ...@@ -205,3 +205,6 @@ csharp_space_between_square_brackets = false
csharp_prefer_braces = true:silent csharp_prefer_braces = true:silent
csharp_preserve_single_line_blocks = true csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = true csharp_preserve_single_line_statements = true
# warning RS0037: PublicAPI.txt is missing '#nullable enable'
dotnet_diagnostic.RS0037.severity = none
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<!-- Versions used by several individual references below --> <!-- Versions used by several individual references below -->
<RoslynDiagnosticsNugetPackageVersion>2.9.6</RoslynDiagnosticsNugetPackageVersion> <RoslynDiagnosticsNugetPackageVersion>3.0.0-beta2.20059.3+77df2220</RoslynDiagnosticsNugetPackageVersion>
<CodeStyleLayerCodeAnalysisVersion>2.8.2</CodeStyleLayerCodeAnalysisVersion> <CodeStyleLayerCodeAnalysisVersion>2.8.2</CodeStyleLayerCodeAnalysisVersion>
<MicrosoftCodeAnalysisTestingVersion>1.0.0-beta1-63310-01</MicrosoftCodeAnalysisTestingVersion> <MicrosoftCodeAnalysisTestingVersion>1.0.0-beta1-63310-01</MicrosoftCodeAnalysisTestingVersion>
<CodeStyleAnalyzerVersion>3.3.1-beta3-19454-05</CodeStyleAnalyzerVersion> <CodeStyleAnalyzerVersion>3.3.1-beta3-19454-05</CodeStyleAnalyzerVersion>
......
...@@ -83,7 +83,7 @@ protected override IEnumerable<SnapshotSpan> GetSpansToTag(ITextView textView, I ...@@ -83,7 +83,7 @@ protected override IEnumerable<SnapshotSpan> GetSpansToTag(ITextView textView, I
return base.GetSpansToTag(textView, subjectBuffer); return base.GetSpansToTag(textView, subjectBuffer);
} }
return new[] { visibleSpanOpt.Value }; return SpecializedCollections.SingletonEnumerable(visibleSpanOpt.Value);
} }
protected override Task ProduceTagsAsync(TaggerContext<IClassificationTag> context) protected override Task ProduceTagsAsync(TaggerContext<IClassificationTag> context)
......
...@@ -176,7 +176,7 @@ private void StoreTagSource(ITextView textViewOpt, ITextBuffer subjectBuffer, Ta ...@@ -176,7 +176,7 @@ private void StoreTagSource(ITextView textViewOpt, ITextBuffer subjectBuffer, Ta
protected virtual IEnumerable<SnapshotSpan> GetSpansToTag(ITextView textViewOpt, ITextBuffer subjectBuffer) protected virtual IEnumerable<SnapshotSpan> GetSpansToTag(ITextView textViewOpt, ITextBuffer subjectBuffer)
{ {
// For a standard tagger, the spans to tag is the span of the entire snapshot. // For a standard tagger, the spans to tag is the span of the entire snapshot.
return new[] { subjectBuffer.CurrentSnapshot.GetFullSpan() }; return SpecializedCollections.SingletonEnumerable(subjectBuffer.CurrentSnapshot.GetFullSpan());
} }
/// <summary> /// <summary>
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // 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.Collections.Generic; using System.Collections.Generic;
using Roslyn.Utilities;
using Xunit.Abstractions; using Xunit.Abstractions;
using Xunit.Sdk; using Xunit.Sdk;
...@@ -31,13 +32,13 @@ public WpfTheoryDiscoverer(IMessageSink diagnosticMessageSink) : base(diagnostic ...@@ -31,13 +32,13 @@ public WpfTheoryDiscoverer(IMessageSink diagnosticMessageSink) : base(diagnostic
protected override IEnumerable<IXunitTestCase> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow) protected override IEnumerable<IXunitTestCase> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow)
{ {
var testCase = new WpfTestCase(_diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, dataRow); var testCase = new WpfTestCase(_diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, dataRow);
return new[] { testCase }; return SpecializedCollections.SingletonEnumerable(testCase);
} }
protected override IEnumerable<IXunitTestCase> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute) protected override IEnumerable<IXunitTestCase> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute)
{ {
var testCase = new WpfTheoryTestCase(_diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod); var testCase = new WpfTheoryTestCase(_diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod);
return new[] { testCase }; return SpecializedCollections.SingletonEnumerable(testCase);
} }
} }
} }
...@@ -10,7 +10,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.KeywordHighlightin ...@@ -10,7 +10,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.KeywordHighlightin
Inherits AbstractKeywordHighlighterTests Inherits AbstractKeywordHighlighterTests
Protected Overrides Function GetOptions() As IEnumerable(Of ParseOptions) Protected Overrides Function GetOptions() As IEnumerable(Of ParseOptions)
Return {TestOptions.Regular} Return SpecializedCollections.SingletonEnumerable(TestOptions.Regular)
End Function End Function
Protected Overloads Function TestAsync(element As XElement) As Threading.Tasks.Task Protected Overloads Function TestAsync(element As XElement) As Threading.Tasks.Task
......
...@@ -674,7 +674,7 @@ private List<SyntaxTrivia> GetPermutedTrivia(CSharpSyntaxNode node, List<XmlElem ...@@ -674,7 +674,7 @@ private List<SyntaxTrivia> GetPermutedTrivia(CSharpSyntaxNode node, List<XmlElem
protected override IEnumerable<AbstractFormattingRule> GetFormattingRules(Document document) protected override IEnumerable<AbstractFormattingRule> GetFormattingRules(Document document)
{ {
return new[] { new ChangeSignatureFormattingRule() }.Concat(Formatter.GetDefaultFormattingRules(document)); return SpecializedCollections.SingletonEnumerable(new ChangeSignatureFormattingRule()).Concat(Formatter.GetDefaultFormattingRules(document));
} }
} }
} }
...@@ -604,7 +604,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ChangeSignature ...@@ -604,7 +604,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ChangeSignature
End Function End Function
Protected Overrides Function GetFormattingRules(document As Document) As IEnumerable(Of AbstractFormattingRule) Protected Overrides Function GetFormattingRules(document As Document) As IEnumerable(Of AbstractFormattingRule)
Return New AbstractFormattingRule() {New ChangeSignatureFormattingRule()}.Concat(Formatter.GetDefaultFormattingRules(document)) Return SpecializedCollections.SingletonEnumerable(Of AbstractFormattingRule)(New ChangeSignatureFormattingRule()).
Concat(Formatter.GetDefaultFormattingRules(document))
End Function End Function
End Class End Class
End Namespace End Namespace
...@@ -18,7 +18,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Completion.KeywordRecommenders.Decl ...@@ -18,7 +18,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Completion.KeywordRecommenders.Decl
' If we have modifiers which exclude it, then definitely not ' If we have modifiers which exclude it, then definitely not
Dim modifiers = context.ModifierCollectionFacts Dim modifiers = context.ModifierCollectionFacts
If Not modifiers.CouldApplyToOneOf(PossibleDeclarationTypes.Accessor) Then If Not modifiers.CouldApplyToOneOf(PossibleDeclarationTypes.Accessor) Then
Return Enumerable.Empty(Of RecommendedKeyword)() Return SpecializedCollections.EmptyEnumerable(Of RecommendedKeyword)()
End If End If
Dim targetToken = context.TargetToken Dim targetToken = context.TargetToken
......
...@@ -61,7 +61,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Completion.KeywordRecommenders.Decl ...@@ -61,7 +61,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Completion.KeywordRecommenders.Decl
' If a previous one had a ParamArray, then nothing is valid anymore, since the ParamArray must ' If a previous one had a ParamArray, then nothing is valid anymore, since the ParamArray must
' always be the last parameter ' always be the last parameter
If parameter.Modifiers.Any(Function(modifier) modifier.Kind = SyntaxKind.ParamArrayKeyword) Then If parameter.Modifiers.Any(Function(modifier) modifier.Kind = SyntaxKind.ParamArrayKeyword) Then
Return Enumerable.Empty(Of RecommendedKeyword)() Return SpecializedCollections.EmptyEnumerable(Of RecommendedKeyword)()
End If End If
' If a previous one had an Optional, then all following must be optional. Following Dev10 behavior, ' If a previous one had an Optional, then all following must be optional. Following Dev10 behavior,
......
...@@ -22,7 +22,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Completion.KeywordRecommenders.Expr ...@@ -22,7 +22,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Completion.KeywordRecommenders.Expr
Dim targetToken = context.TargetToken Dim targetToken = context.TargetToken
If context.SyntaxTree.IsExpressionContext(targetToken.SpanStart, cancellationToken, context.SemanticModel) Then If context.SyntaxTree.IsExpressionContext(targetToken.SpanStart, cancellationToken, context.SemanticModel) Then
If targetToken.IsKindOrHasMatchingText(SyntaxKind.IteratorKeyword) Then If targetToken.IsKindOrHasMatchingText(SyntaxKind.IteratorKeyword) Then
Return {New RecommendedKeyword("Function", VBFeaturesResources.Defines_a_lambda_expression_that_calculates_and_returns_a_single_value_Can_be_used_wherever_a_delegate_type_is_expected_Function_parameterList_expression)} Return SpecializedCollections.SingletonEnumerable(
New RecommendedKeyword("Function", VBFeaturesResources.Defines_a_lambda_expression_that_calculates_and_returns_a_single_value_Can_be_used_wherever_a_delegate_type_is_expected_Function_parameterList_expression))
ElseIf targetToken.IsKindOrHasMatchingText(SyntaxKind.AsyncKeyword) Then ElseIf targetToken.IsKindOrHasMatchingText(SyntaxKind.AsyncKeyword) Then
Return {New RecommendedKeyword("Function", VBFeaturesResources.Defines_a_lambda_expression_that_calculates_and_returns_a_single_value_Can_be_used_wherever_a_delegate_type_is_expected_Function_parameterList_expression), Return {New RecommendedKeyword("Function", VBFeaturesResources.Defines_a_lambda_expression_that_calculates_and_returns_a_single_value_Can_be_used_wherever_a_delegate_type_is_expected_Function_parameterList_expression),
New RecommendedKeyword("Sub", VBFeaturesResources.Defines_a_lambda_expression_that_can_execute_statements_and_does_not_return_a_value_Can_be_used_wherever_a_delegate_type_is_expected_Sub_parameterList_statement)} New RecommendedKeyword("Sub", VBFeaturesResources.Defines_a_lambda_expression_that_can_execute_statements_and_does_not_return_a_value_Can_be_used_wherever_a_delegate_type_is_expected_Sub_parameterList_statement)}
......
...@@ -11,13 +11,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Completion.KeywordRecommenders.Expr ...@@ -11,13 +11,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Completion.KeywordRecommenders.Expr
Protected Overrides Function RecommendKeywords(context As VisualBasicSyntaxContext, cancellationToken As CancellationToken) As IEnumerable(Of RecommendedKeyword) Protected Overrides Function RecommendKeywords(context As VisualBasicSyntaxContext, cancellationToken As CancellationToken) As IEnumerable(Of RecommendedKeyword)
If context.IsAnyExpressionContext Then If context.IsAnyExpressionContext Then
Return {CreateRecommendedKeywordForIntrinsicOperator( Return SpecializedCollections.SingletonEnumerable(CreateRecommendedKeywordForIntrinsicOperator(
SyntaxKind.NameOfKeyword, SyntaxKind.NameOfKeyword,
VBFeaturesResources.NameOf_function, VBFeaturesResources.NameOf_function,
Glyph.MethodPublic, Glyph.MethodPublic,
New NameOfExpressionDocumentation(), New NameOfExpressionDocumentation(),
context.SemanticModel, context.SemanticModel,
context.Position)} context.Position))
End If End If
Return SpecializedCollections.EmptyEnumerable(Of RecommendedKeyword)() Return SpecializedCollections.EmptyEnumerable(Of RecommendedKeyword)()
......
...@@ -271,12 +271,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue ...@@ -271,12 +271,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue
' Property: Attributes Modifiers [|Identifier$ Initializer|] ImplementsClause ' Property: Attributes Modifiers [|Identifier$ Initializer|] ImplementsClause
Dim propertyStatement = DirectCast(node, PropertyStatementSyntax) Dim propertyStatement = DirectCast(node, PropertyStatementSyntax)
If propertyStatement.Initializer IsNot Nothing Then If propertyStatement.Initializer IsNot Nothing Then
Return {propertyStatement.Identifier}.Concat(If(propertyStatement.AsClause?.DescendantTokens(), Return SpecializedCollections.SingletonEnumerable(propertyStatement.Identifier).Concat(If(propertyStatement.AsClause?.DescendantTokens(),
Array.Empty(Of SyntaxToken))).Concat(propertyStatement.Initializer.DescendantTokens()) Array.Empty(Of SyntaxToken))).Concat(propertyStatement.Initializer.DescendantTokens())
End If End If
If HasAsNewClause(propertyStatement) Then If HasAsNewClause(propertyStatement) Then
Return {propertyStatement.Identifier}.Concat(propertyStatement.AsClause.DescendantTokens()) Return SpecializedCollections.SingletonEnumerable(propertyStatement.Identifier).Concat(propertyStatement.AsClause.DescendantTokens())
End If End If
Return Nothing Return Nothing
......
...@@ -572,7 +572,9 @@ public override void Initialize(AnalysisContext context) ...@@ -572,7 +572,9 @@ public override void Initialize(AnalysisContext context)
public sealed class AnalyzerWithCSharpCompilerDiagnosticId : DiagnosticAnalyzer public sealed class AnalyzerWithCSharpCompilerDiagnosticId : DiagnosticAnalyzer
{ {
public static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor( public static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(
#pragma warning disable RS1029 // Do not use reserved diagnostic IDs.
"CS101", "CS101",
#pragma warning restore RS1029 // Do not use reserved diagnostic IDs.
"Title1", "Title1",
"Message1", "Message1",
"Category1", "Category1",
...@@ -591,7 +593,9 @@ public override void Initialize(AnalysisContext context) ...@@ -591,7 +593,9 @@ public override void Initialize(AnalysisContext context)
public sealed class AnalyzerWithBasicCompilerDiagnosticId : DiagnosticAnalyzer public sealed class AnalyzerWithBasicCompilerDiagnosticId : DiagnosticAnalyzer
{ {
public static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor( public static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(
#pragma warning disable RS1029 // Do not use reserved diagnostic IDs.
"BC101", "BC101",
#pragma warning restore RS1029 // Do not use reserved diagnostic IDs.
"Title1", "Title1",
"Message1", "Message1",
"Category1", "Category1",
......
...@@ -23,7 +23,9 @@ public abstract class TestDiagnosticAnalyzer<TLanguageKindEnum> : DiagnosticAnal ...@@ -23,7 +23,9 @@ public abstract class TestDiagnosticAnalyzer<TLanguageKindEnum> : DiagnosticAnal
// protected static readonly ImmutableArray<string> AllAbstractMemberNames = ImmutableArray<string>.Empty.AddRange(GetAbstractMemberNames(typeof(CompilationStartAnalysisScope)).Distinct()); // protected static readonly ImmutableArray<string> AllAbstractMemberNames = ImmutableArray<string>.Empty.AddRange(GetAbstractMemberNames(typeof(CompilationStartAnalysisScope)).Distinct());
protected static readonly DiagnosticDescriptor DefaultDiagnostic = protected static readonly DiagnosticDescriptor DefaultDiagnostic =
#pragma warning disable RS1029 // Do not use reserved diagnostic IDs.
new DiagnosticDescriptor("CA7777", "CA7777_AnalyzerTestDiagnostic", "I'm here for test purposes", "Test", DiagnosticSeverity.Warning, isEnabledByDefault: true); new DiagnosticDescriptor("CA7777", "CA7777_AnalyzerTestDiagnostic", "I'm here for test purposes", "Test", DiagnosticSeverity.Warning, isEnabledByDefault: true);
#pragma warning restore RS1029 // Do not use reserved diagnostic IDs.
private static ImmutableArray<T> GetAllEnumValues<T>() private static ImmutableArray<T> GetAllEnumValues<T>()
{ {
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
using Microsoft.Internal.VisualStudio.PlatformUI; using Microsoft.Internal.VisualStudio.PlatformUI;
using Microsoft.VisualStudio.Imaging.Interop; using Microsoft.VisualStudio.Imaging.Interop;
using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Shell;
using Roslyn.Utilities;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.SolutionExplorer namespace Microsoft.VisualStudio.LanguageServices.Implementation.SolutionExplorer
{ {
...@@ -43,7 +44,7 @@ public IEnumerable<string> Children ...@@ -43,7 +44,7 @@ public IEnumerable<string> Children
{ {
get get
{ {
return Enumerable.Empty<string>(); return SpecializedCollections.EmptyEnumerable<string>();
} }
} }
......
...@@ -10,6 +10,7 @@ Imports Microsoft.CodeAnalysis.Test.Utilities ...@@ -10,6 +10,7 @@ Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Microsoft.VisualStudio.LanguageServices.Implementation Imports Microsoft.VisualStudio.LanguageServices.Implementation
Imports Microsoft.Win32 Imports Microsoft.Win32
Imports Roslyn.Test.Utilities Imports Roslyn.Test.Utilities
Imports Roslyn.Utilities
Namespace Microsoft.VisualStudio.LanguageServices.UnitTests Namespace Microsoft.VisualStudio.LanguageServices.UnitTests
<[UseExportProvider]> <[UseExportProvider]>
...@@ -22,7 +23,8 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests ...@@ -22,7 +23,8 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests
Dim mscorlib As AssemblyIdentity = Nothing Dim mscorlib As AssemblyIdentity = Nothing
AssemblyIdentity.TryParseDisplayName(s_mscorlibDisplayName, mscorlib) AssemblyIdentity.TryParseDisplayName(s_mscorlibDisplayName, mscorlib)
Return {New IgnorableAssemblyIdentityList({mscorlib})} Return SpecializedCollections.SingletonEnumerable(
New IgnorableAssemblyIdentityList(SpecializedCollections.SingletonEnumerable(mscorlib)))
End Function End Function
<Fact> <Fact>
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
using Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem; using Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem;
using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop; using Microsoft.VisualStudio.Shell.Interop;
using Roslyn.Utilities;
namespace Microsoft.VisualStudio.LanguageServices.LiveShare.Client.Debugging namespace Microsoft.VisualStudio.LanguageServices.LiveShare.Client.Debugging
{ {
...@@ -22,7 +23,7 @@ internal class CSharpLspPackage : AbstractPackage<CSharpLspPackage, CSharpLspLan ...@@ -22,7 +23,7 @@ internal class CSharpLspPackage : AbstractPackage<CSharpLspPackage, CSharpLspLan
protected override IEnumerable<IVsEditorFactory> CreateEditorFactories() protected override IEnumerable<IVsEditorFactory> CreateEditorFactories()
{ {
return new IVsEditorFactory[] { }; return SpecializedCollections.EmptyEnumerable<IVsEditorFactory>();
} }
protected override CSharpLspLanguageService CreateLanguageService() => new CSharpLspLanguageService(this); protected override CSharpLspLanguageService CreateLanguageService() => new CSharpLspLanguageService(this);
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor; using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Tagging; using Microsoft.VisualStudio.Text.Tagging;
using Roslyn.Utilities;
namespace Microsoft.VisualStudio.LanguageServices.LiveShare.Client.Tagger namespace Microsoft.VisualStudio.LanguageServices.LiveShare.Client.Tagger
{ {
...@@ -69,7 +70,7 @@ protected override IEnumerable<SnapshotSpan> GetSpansToTag(ITextView textView, I ...@@ -69,7 +70,7 @@ protected override IEnumerable<SnapshotSpan> GetSpansToTag(ITextView textView, I
if (textView == null) if (textView == null)
{ {
var currentSnapshot = subjectBuffer.CurrentSnapshot; var currentSnapshot = subjectBuffer.CurrentSnapshot;
return new[] { new SnapshotSpan(currentSnapshot, Span.FromBounds(0, currentSnapshot.Length)) }; return SpecializedCollections.SingletonEnumerable(new SnapshotSpan(currentSnapshot, Span.FromBounds(0, currentSnapshot.Length)));
} }
// Determine the range of text that is visible in the view. Then map this down to our // Determine the range of text that is visible in the view. Then map this down to our
...@@ -86,7 +87,7 @@ protected override IEnumerable<SnapshotSpan> GetSpansToTag(ITextView textView, I ...@@ -86,7 +87,7 @@ protected override IEnumerable<SnapshotSpan> GetSpansToTag(ITextView textView, I
// are no visible spans in the buffer return the full snapshot. // are no visible spans in the buffer return the full snapshot.
// This can occur in an HTML file with script blocks when the user // This can occur in an HTML file with script blocks when the user
// scrolls down and the script blocks are no longer visible in view. // scrolls down and the script blocks are no longer visible in view.
return new[] { new SnapshotSpan(snapshot, 0, snapshot.Length) }; return SpecializedCollections.SingletonEnumerable(new SnapshotSpan(snapshot, 0, snapshot.Length));
} }
var visibleStart = visibleSpansInBuffer.First().Start; var visibleStart = visibleSpansInBuffer.First().Start;
...@@ -105,7 +106,7 @@ protected override IEnumerable<SnapshotSpan> GetSpansToTag(ITextView textView, I ...@@ -105,7 +106,7 @@ protected override IEnumerable<SnapshotSpan> GetSpansToTag(ITextView textView, I
var span = new SnapshotSpan(snapshot, Span.FromBounds(start, end)); var span = new SnapshotSpan(snapshot, Span.FromBounds(start, end));
return new[] { span }; return SpecializedCollections.SingletonEnumerable(span);
} }
} }
} }
...@@ -313,7 +313,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic ...@@ -313,7 +313,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Select(Function(n) semanticModel.GetDeclaredSymbol(n, cancellationToken)) Select(Function(n) semanticModel.GetDeclaredSymbol(n, cancellationToken))
End If End If
Return {semanticModel.GetDeclaredSymbol(memberDeclaration, cancellationToken)} Return SpecializedCollections.SingletonEnumerable(semanticModel.GetDeclaredSymbol(memberDeclaration, cancellationToken))
End Function End Function
Public Function FindParameterForArgument(semanticModel As SemanticModel, argumentNode As SyntaxNode, cancellationToken As CancellationToken) As IParameterSymbol Implements ISemanticFactsService.FindParameterForArgument Public Function FindParameterForArgument(semanticModel As SemanticModel, argumentNode As SyntaxNode, cancellationToken As CancellationToken) As IParameterSymbol Implements ISemanticFactsService.FindParameterForArgument
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册