зеркало из https://github.com/dotnet/razor.git
Clean up a couple Linting problems (#3121)
Clean up a couple Linting problems
This commit is contained in:
Родитель
4d5d674d35
Коммит
6ed9535a1d
|
@ -42,8 +42,8 @@
|
|||
<EditorConfigFiles Include="$(RepositoryEngineeringDir)config\globalconfigs\Common.globalconfig" />
|
||||
<!-- Include Shipping.globalconfig for shipping projects -->
|
||||
<EditorConfigFiles Condition="'$(IsShipping)' == 'true'" Include="$(RepositoryEngineeringDir)config\globalconfigs\Shipping.globalconfig" />
|
||||
<!-- Include NonShipping.globalconfig for non-shipping projects -->
|
||||
<EditorConfigFiles Condition="'$(IsShipping)' != 'true'" Include="$(RepositoryEngineeringDir)config\globalconfigs\NonShipping.globalconfig" />
|
||||
<!-- Include NonShipping.globalconfig for non-shipping projects, except for API shims -->
|
||||
<EditorConfigFiles Condition="'$(IsShipping)' != 'true' AND '$(IsApiShim)' != 'true'" Include="$(RepositoryEngineeringDir)config\globalconfigs\NonShipping.globalconfig" />
|
||||
<!-- Include ApiShim.globalconfig for API shim projects -->
|
||||
<EditorConfigFiles Condition="'$(IsApiShim)' == 'true'" Include="$(RepositoryEngineeringDir)config\globalconfigs\ApiShim.globalconfig" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -5,8 +5,26 @@ is_global = true
|
|||
# CA1816: Call GC.SuppressFinalize correctly
|
||||
dotnet_diagnostic.CA1816.severity = none
|
||||
|
||||
# CA1822: Member 'Member' does not access instance data and can be marked as static
|
||||
dotnet_diagnostic.CA1822.severity = none
|
||||
|
||||
# CA2227: Change 'Member' to be read-only by removing the property setter
|
||||
dotnet_diagnostic.CA2227.severity = none
|
||||
|
||||
# IDE0044: Add readonly modifier
|
||||
dotnet_diagnostic.IDE0044.severity = none
|
||||
|
||||
# IDE0060: Remove unused parameter
|
||||
dotnet_diagnostic.IDE0060.severity = none
|
||||
|
||||
# RS0016: Add public types and members to the declared API
|
||||
dotnet_diagnostic.RS0016.severity = none
|
||||
|
||||
# RS0026: Do not add multiple public overloads with optional parameters
|
||||
dotnet_diagnostic.RS0026.severity = none
|
||||
|
||||
# RS0027: Public API with optional parameter(s) should have the most parameters amongst its public overloads
|
||||
dotnet_diagnostic.RS0027.severity = none
|
||||
|
||||
# RS0037: Enable tracking of nullability of reference types in the declared API
|
||||
dotnet_diagnostic.RS0037.severity = none
|
||||
|
|
|
@ -172,7 +172,6 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Formatting
|
|||
foreach (var mapping in context.CodeDocument.GetCSharpDocument().SourceMappings)
|
||||
{
|
||||
var mappingSpan = new TextSpan(mapping.OriginalSpan.AbsoluteIndex, mapping.OriginalSpan.Length);
|
||||
var mappingRange = mappingSpan.AsRange(context.SourceText);
|
||||
if (!ShouldFormat(context, mappingSpan, allowImplicitStatements: true))
|
||||
{
|
||||
// We don't care about this range as this can potentially lead to incorrect scopes.
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer
|
|||
|
||||
public RazorLSPOptions Get(string name)
|
||||
{
|
||||
name = name ?? Options.DefaultName;
|
||||
name ??= Options.DefaultName;
|
||||
return _cache.GetOrAdd(name, () => _currentValue);
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace Microsoft.CodeAnalysis.Razor.Completion
|
|||
|
||||
// Also helps filter out edge cases like `< te` and `< te=""`
|
||||
// (see comment in AtMarkupTransitionCompletionPoint)
|
||||
if (!_htmlFactsService.TryGetElementInfo(parent, out var containingTagNameToken, out var attributes) ||
|
||||
if (!_htmlFactsService.TryGetElementInfo(parent, out var containingTagNameToken, out _) ||
|
||||
!containingTagNameToken.Span.IntersectsWith(location.AbsoluteIndex))
|
||||
{
|
||||
return Array.Empty<RazorCompletionItem>();
|
||||
|
|
|
@ -44,13 +44,13 @@ namespace Microsoft.CodeAnalysis.Razor
|
|||
//
|
||||
// This service is only used in process in Visual Studio, and any other callers should provide these
|
||||
// things also.
|
||||
configure = configure ?? ((b) => { });
|
||||
configure ??= ((b) => { });
|
||||
|
||||
// The default configuration currently matches the newest MVC configuration.
|
||||
//
|
||||
// We typically want this because the language adds features over time - we don't want to a bunch of errors
|
||||
// to show up when a document is first opened, and then go away when the configuration loads, we'd prefer the opposite.
|
||||
configuration = configuration ?? DefaultConfiguration;
|
||||
configuration ??= DefaultConfiguration;
|
||||
|
||||
// If there's no factory to handle the configuration then fall back to a very basic configuration.
|
||||
//
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
throw new ArgumentNullException(nameof(hostDocument));
|
||||
}
|
||||
|
||||
loader = loader ?? EmptyLoader;
|
||||
loader ??= EmptyLoader;
|
||||
return new DocumentState(services, hostDocument, null, null, loader);
|
||||
}
|
||||
|
||||
|
@ -172,12 +172,13 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
|
||||
public virtual DocumentState WithConfigurationChange()
|
||||
{
|
||||
var state = new DocumentState(Services, HostDocument, _sourceText, _version, _loader);
|
||||
|
||||
// The source could not have possibly changed.
|
||||
state._sourceText = _sourceText;
|
||||
state._version = _version;
|
||||
state._loaderTask = _loaderTask;
|
||||
var state = new DocumentState(Services, HostDocument, _sourceText, _version, _loader)
|
||||
{
|
||||
// The source could not have possibly changed.
|
||||
_sourceText = _sourceText,
|
||||
_version = _version,
|
||||
_loaderTask = _loaderTask
|
||||
};
|
||||
|
||||
// Do not cache computed state
|
||||
|
||||
|
@ -186,12 +187,13 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
|
||||
public virtual DocumentState WithImportsChange()
|
||||
{
|
||||
var state = new DocumentState(Services, HostDocument, _sourceText, _version, _loader);
|
||||
|
||||
// The source could not have possibly changed.
|
||||
state._sourceText = _sourceText;
|
||||
state._version = _version;
|
||||
state._loaderTask = _loaderTask;
|
||||
var state = new DocumentState(Services, HostDocument, _sourceText, _version, _loader)
|
||||
{
|
||||
// The source could not have possibly changed.
|
||||
_sourceText = _sourceText,
|
||||
_version = _version,
|
||||
_loaderTask = _loaderTask
|
||||
};
|
||||
|
||||
// Optimisically cache the computed state
|
||||
state._computedState = new ComputedStateTracker(state, _computedState);
|
||||
|
@ -201,12 +203,13 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
|
||||
public virtual DocumentState WithProjectWorkspaceStateChange()
|
||||
{
|
||||
var state = new DocumentState(Services, HostDocument, _sourceText, _version, _loader);
|
||||
|
||||
// The source could not have possibly changed.
|
||||
state._sourceText = _sourceText;
|
||||
state._version = _version;
|
||||
state._loaderTask = _loaderTask;
|
||||
var state = new DocumentState(Services, HostDocument, _sourceText, _version, _loader)
|
||||
{
|
||||
// The source could not have possibly changed.
|
||||
_sourceText = _sourceText,
|
||||
_version = _version,
|
||||
_loaderTask = _loaderTask
|
||||
};
|
||||
|
||||
// Optimisically cache the computed state
|
||||
state._computedState = new ComputedStateTracker(state, _computedState);
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
|
||||
public bool Equals(ProjectWorkspaceState other)
|
||||
{
|
||||
if (object.ReferenceEquals(other, null))
|
||||
if (other is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -69,4 +69,4 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
return hash.CombinedHash;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,8 +198,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
|
||||
foreach (var classDeclaration in classDeclarations)
|
||||
{
|
||||
var classSymbol = semanticModel.GetDeclaredSymbol(classDeclaration) as INamedTypeSymbol;
|
||||
if (classSymbol == null)
|
||||
if (!(semanticModel.GetDeclaredSymbol(classDeclaration) is INamedTypeSymbol classSymbol))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace Microsoft.CodeAnalysis.Razor
|
|||
// The default configuration currently matches MVC-2.0. Beyond MVC-2.0 we added SDK support for
|
||||
// properly detecting project versions, so that's a good version to assume when we can't find a
|
||||
// configuration.
|
||||
configuration = configuration ?? DefaultConfiguration;
|
||||
configuration ??= DefaultConfiguration;
|
||||
|
||||
// If there's no factory to handle the configuration then fall back to a very basic configuration.
|
||||
//
|
||||
|
|
|
@ -95,8 +95,7 @@ namespace Microsoft.VisualStudio.Editor.Razor
|
|||
// one of them for a tracker because the content type could have changed.
|
||||
foreach (var textBuffer in subjectBuffers)
|
||||
{
|
||||
DefaultVisualStudioDocumentTracker documentTracker;
|
||||
if (textBuffer.Properties.TryGetProperty(typeof(VisualStudioDocumentTracker), out documentTracker))
|
||||
if (textBuffer.Properties.TryGetProperty(typeof(VisualStudioDocumentTracker), out DefaultVisualStudioDocumentTracker documentTracker))
|
||||
{
|
||||
documentTracker.RemoveTextView(textView);
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace Microsoft.VisualStudio.Editor.Razor.Documents
|
|||
|
||||
private void OnTextBufferChanged(object sender, TextContentChangedEventArgs e)
|
||||
{
|
||||
if (sender is ITextBuffer buffer)
|
||||
if (sender is ITextBuffer)
|
||||
{
|
||||
var snapshot = _snapshot;
|
||||
if (snapshot != null && snapshot.Version != null && e.AfterVersion != null &&
|
||||
|
|
|
@ -307,7 +307,6 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor.HtmlCSharp
|
|||
{
|
||||
var triggerCharEnumeration = mergedCapabilities.OnAutoInsertProvider?.TriggerCharacters ?? Enumerable.Empty<string>();
|
||||
var onAutoInsertMergedTriggerChars = new HashSet<string>(triggerCharEnumeration);
|
||||
var vsServerCapabilities = InitializeResult.Capabilities as VSServerCapabilities;
|
||||
if (!onAutoInsertMergedTriggerChars.SetEquals(triggerCharEnumeration))
|
||||
{
|
||||
await _joinableTaskFactory.SwitchToMainThreadAsync();
|
||||
|
@ -426,8 +425,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor.HtmlCSharp
|
|||
|
||||
foreach (var languageClientAndMetadata in _languageServiceBroker.LanguageClients)
|
||||
{
|
||||
var metadata = languageClientAndMetadata.Metadata as ILanguageClientMetadata;
|
||||
if (metadata == null)
|
||||
if (!(languageClientAndMetadata.Metadata is ILanguageClientMetadata metadata))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor
|
|||
return null;
|
||||
}
|
||||
|
||||
_documentTable.FindDocument(textDocument.FilePath, out var hierarchy, out uint itemId, out uint cookie);
|
||||
_documentTable.FindDocument(textDocument.FilePath, out var hierarchy, out _, out _);
|
||||
|
||||
// We don't currently try to look a Roslyn ProjectId at this point, we just want to know some
|
||||
// basic things.
|
||||
|
|
|
@ -53,11 +53,10 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
_projectManager = projectManager;
|
||||
|
||||
// Attach the event sink to solution update events.
|
||||
var solutionBuildManager = _services.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager;
|
||||
if (solutionBuildManager != null)
|
||||
if (_services.GetService(typeof(SVsSolutionBuildManager)) is IVsSolutionBuildManager solutionBuildManager)
|
||||
{
|
||||
// We expect this to be called only once. So we don't need to Unadvise.
|
||||
var hr = solutionBuildManager.AdviseUpdateSolutionEvents(this, out var cookie);
|
||||
var hr = solutionBuildManager.AdviseUpdateSolutionEvents(this, out _);
|
||||
Marshal.ThrowExceptionForHR(hr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) .NET Foundation. 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 Microsoft.AspNetCore.Razor.Language;
|
||||
using Xunit;
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.AutoInsert
|
|||
var context = FormattingContext.Create(uri, Mock.Of<DocumentSnapshot>(MockBehavior.Strict), codeDocument, options, new Range(position, position));
|
||||
|
||||
// Act
|
||||
if (!provider.TryResolveInsertion(position, context, out var edit, out var format))
|
||||
if (!provider.TryResolveInsertion(position, context, out var edit, out _))
|
||||
{
|
||||
edit = null;
|
||||
}
|
||||
|
|
|
@ -316,7 +316,7 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Completion
|
|||
|
||||
private static RazorSyntaxTree GetSyntaxTree(string text, string fileKind = null)
|
||||
{
|
||||
fileKind = fileKind ?? FileKinds.Component;
|
||||
fileKind ??= FileKinds.Component;
|
||||
var sourceDocument = TestRazorSourceDocument.Create(text);
|
||||
var projectEngine = RazorProjectEngine.Create(builder => { });
|
||||
var codeDocument = projectEngine.ProcessDesignTime(sourceDocument, fileKind, Array.Empty<RazorSourceDocument>(), Array.Empty<TagHelperDescriptor>());
|
||||
|
|
|
@ -94,14 +94,14 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer
|
|||
projectSnapshotManager.DocumentAdded(document.ProjectInternal.HostProject, document.State.HostDocument, TextLoader.From(textAndVersion));
|
||||
|
||||
// Act - 1
|
||||
var result = documentVersionCache.TryGetDocumentVersion(document, out var version);
|
||||
var result = documentVersionCache.TryGetDocumentVersion(document, out _);
|
||||
|
||||
// Assert - 1
|
||||
Assert.True(result);
|
||||
|
||||
// Act - 2
|
||||
projectSnapshotManager.DocumentRemoved(document.ProjectInternal.HostProject, document.State.HostDocument);
|
||||
result = documentVersionCache.TryGetDocumentVersion(document, out version);
|
||||
result = documentVersionCache.TryGetDocumentVersion(document, out _);
|
||||
|
||||
// Assert - 2
|
||||
Assert.True(result);
|
||||
|
@ -125,7 +125,7 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer
|
|||
projectSnapshotManager.DocumentOpened(document.ProjectInternal.FilePath, document.FilePath, textAndVersion.Text);
|
||||
|
||||
// Act - 1
|
||||
var result = documentVersionCache.TryGetDocumentVersion(document, out var version);
|
||||
var result = documentVersionCache.TryGetDocumentVersion(document, out _);
|
||||
|
||||
// Assert - 1
|
||||
Assert.True(result);
|
||||
|
@ -133,7 +133,7 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer
|
|||
|
||||
// Act - 2
|
||||
projectSnapshotManager.DocumentRemoved(document.ProjectInternal.HostProject, document.State.HostDocument);
|
||||
result = documentVersionCache.TryGetDocumentVersion(document, out version);
|
||||
result = documentVersionCache.TryGetDocumentVersion(document, out _);
|
||||
|
||||
// Assert - 2
|
||||
Assert.True(result);
|
||||
|
@ -157,14 +157,14 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer
|
|||
projectSnapshotManager.DocumentAdded(document.ProjectInternal.HostProject, document.State.HostDocument, textLoader);
|
||||
|
||||
// Act - 1
|
||||
var result = documentVersionCache.TryGetDocumentVersion(document, out var version);
|
||||
var result = documentVersionCache.TryGetDocumentVersion(document, out _);
|
||||
|
||||
// Assert - 1
|
||||
Assert.True(result);
|
||||
|
||||
// Act - 2
|
||||
projectSnapshotManager.DocumentClosed(document.ProjectInternal.HostProject.FilePath, document.State.HostDocument.FilePath, textLoader);
|
||||
result = documentVersionCache.TryGetDocumentVersion(document, out version);
|
||||
result = documentVersionCache.TryGetDocumentVersion(document, out var version);
|
||||
|
||||
// Assert - 2
|
||||
Assert.False(result);
|
||||
|
|
|
@ -240,7 +240,7 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Test
|
|||
|
||||
private static RazorCodeDocument CreateComponentDocument(string text, params TagHelperDescriptor[] tagHelpers)
|
||||
{
|
||||
tagHelpers = tagHelpers ?? Array.Empty<TagHelperDescriptor>();
|
||||
tagHelpers ??= Array.Empty<TagHelperDescriptor>();
|
||||
var sourceDocument = TestRazorSourceDocument.Create(text);
|
||||
var projectEngine = RazorProjectEngine.Create(builder => { });
|
||||
var codeDocument = projectEngine.ProcessDesignTime(sourceDocument, FileKinds.Component, Array.Empty<RazorSourceDocument>(), tagHelpers);
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
|
|
@ -489,7 +489,7 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Refactoring.Test
|
|||
d.TryResolveDocument(itemDirectory2.FilePath, out directory2Component) == true, MockBehavior.Strict);
|
||||
|
||||
var searchEngine = new DefaultRazorComponentSearchEngine(Dispatcher, projectSnapshotManagerAccessor);
|
||||
languageServerFeatureOptions = languageServerFeatureOptions ?? Mock.Of<LanguageServerFeatureOptions>(options => options.SupportsFileManipulation == true, MockBehavior.Strict);
|
||||
languageServerFeatureOptions ??= Mock.Of<LanguageServerFeatureOptions>(options => options.SupportsFileManipulation == true, MockBehavior.Strict);
|
||||
var endpoint = new RazorComponentRenameEndpoint(Dispatcher, documentResolver, searchEngine, projectSnapshotManagerAccessor, languageServerFeatureOptions);
|
||||
return endpoint;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
|
|
@ -286,8 +286,8 @@ namespace Microsoft.AspNetCore.Razor.OmniSharpPlugin
|
|||
|
||||
private TagHelperRefreshTrigger CreateRefreshTrigger(OmniSharpProjectWorkspaceStateGenerator workspaceStateGenerator = null, Workspace workspace = null, int enqueueDelay = 1)
|
||||
{
|
||||
workspaceStateGenerator = workspaceStateGenerator ?? Mock.Of<OmniSharpProjectWorkspaceStateGenerator>(MockBehavior.Strict);
|
||||
workspace = workspace ?? Workspace;
|
||||
workspaceStateGenerator ??= Mock.Of<OmniSharpProjectWorkspaceStateGenerator>(MockBehavior.Strict);
|
||||
workspace ??= Workspace;
|
||||
var refreshTrigger = new TagHelperRefreshTrigger(Dispatcher, workspace, workspaceStateGenerator)
|
||||
{
|
||||
EnqueueDelay = enqueueDelay,
|
||||
|
|
|
@ -254,7 +254,6 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
|
|||
|
||||
private static void WriteBaseline(string text, string filePath)
|
||||
{
|
||||
var lines = text.Replace("\r", "").Replace("\n", "\r\n");
|
||||
File.WriteAllText(filePath, text);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
|
|||
{
|
||||
builder
|
||||
.AppendLine(location.ToString())
|
||||
.Append("|");
|
||||
.Append('|');
|
||||
|
||||
for (var i = 0; i < location.Length; i++)
|
||||
{
|
||||
|
|
|
@ -194,7 +194,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
|
||||
internal virtual RazorSyntaxTree ParseDocument(RazorLanguageVersion version, string document, IEnumerable<DirectiveDescriptor> directives, bool designTime = false, RazorParserFeatureFlags featureFlags = null, string fileKind = null)
|
||||
{
|
||||
directives = directives ?? Array.Empty<DirectiveDescriptor>();
|
||||
directives ??= Array.Empty<DirectiveDescriptor>();
|
||||
|
||||
var source = TestRazorSourceDocument.Create(document, filePath: null, relativePath: null, normalizeNewLines: true);
|
||||
|
||||
|
|
|
@ -113,11 +113,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Syntax
|
|||
|
||||
var builder = new StringBuilder("Directive:{");
|
||||
builder.Append(node.DirectiveDescriptor.Directive);
|
||||
builder.Append(";");
|
||||
builder.Append(';');
|
||||
builder.Append(node.DirectiveDescriptor.Kind);
|
||||
builder.Append(";");
|
||||
builder.Append(';');
|
||||
builder.Append(node.DirectiveDescriptor.Usage);
|
||||
builder.Append("}");
|
||||
builder.Append('}');
|
||||
|
||||
var diagnostics = node.GetDiagnostics();
|
||||
if (diagnostics.Length > 0)
|
||||
|
@ -125,7 +125,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Syntax
|
|||
builder.Append(" [");
|
||||
var ids = string.Join(", ", diagnostics.Select(diagnostic => $"{diagnostic.Id}{diagnostic.Span}"));
|
||||
builder.Append(ids);
|
||||
builder.Append("]");
|
||||
builder.Append(']');
|
||||
}
|
||||
|
||||
WriteSeparator();
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
public static MemoryStream CreateStreamContent(string content = "Hello, World!", Encoding encoding = null, bool normalizeNewLines = false)
|
||||
{
|
||||
var stream = new MemoryStream();
|
||||
encoding = encoding ?? Encoding.UTF8;
|
||||
encoding ??= Encoding.UTF8;
|
||||
using (var writer = new StreamWriter(stream, encoding, bufferSize: 1024, leaveOpen: true))
|
||||
{
|
||||
if (normalizeNewLines)
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace Microsoft.CodeAnalysis.Razor.Completion
|
|||
var node = GetNodeAt("<p bin>", 4);
|
||||
|
||||
// Act
|
||||
var result = DirectiveAttributeCompletionItemProviderBase.TryGetAttributeInfo(node, out var prefixLocation, out var name, out var nameLocation, out var parameterName, out var parameterNameLocation);
|
||||
var result = DirectiveAttributeCompletionItemProviderBase.TryGetAttributeInfo(node, out var prefixLocation, out var name, out var nameLocation, out var parameterName, out _);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
|
@ -66,7 +66,7 @@ namespace Microsoft.CodeAnalysis.Razor.Completion
|
|||
var node = GetNodeAt("<p @>", 4);
|
||||
|
||||
// Act
|
||||
var result = DirectiveAttributeCompletionItemProviderBase.TryGetAttributeInfo(node, out var prefixLocation, out var name, out var nameLocation, out var parameterName, out var parameterNameLocation);
|
||||
var result = DirectiveAttributeCompletionItemProviderBase.TryGetAttributeInfo(node, out var prefixLocation, out var name, out var nameLocation, out var parameterName, out _);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
|
@ -83,7 +83,7 @@ namespace Microsoft.CodeAnalysis.Razor.Completion
|
|||
var node = GetNodeAt("<p foo=\"anything\">", 4);
|
||||
|
||||
// Act
|
||||
var result = DirectiveAttributeCompletionItemProviderBase.TryGetAttributeInfo(node, out var prefixLocation, out var name, out var nameLocation, out var parameterName, out var parameterNameLocation);
|
||||
var result = DirectiveAttributeCompletionItemProviderBase.TryGetAttributeInfo(node, out var prefixLocation, out var name, out var nameLocation, out var parameterName, out _);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
|
@ -99,7 +99,7 @@ namespace Microsoft.CodeAnalysis.Razor.Completion
|
|||
var node = GetNodeAt("<input type=\"text\" @bind />", 22);
|
||||
|
||||
// Act
|
||||
var result = DirectiveAttributeCompletionItemProviderBase.TryGetAttributeInfo(node, out var prefixLocation, out var name, out var nameLocation, out var parameterName, out var parameterNameLocation);
|
||||
var result = DirectiveAttributeCompletionItemProviderBase.TryGetAttributeInfo(node, out var prefixLocation, out var name, out var nameLocation, out var parameterName, out _);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
|
@ -118,7 +118,7 @@ namespace Microsoft.CodeAnalysis.Razor.Completion
|
|||
}", 22);
|
||||
|
||||
// Act
|
||||
var result = DirectiveAttributeCompletionItemProviderBase.TryGetAttributeInfo(node, out var prefixLocation, out var name, out var nameLocation, out var parameterName, out var parameterNameLocation);
|
||||
var result = DirectiveAttributeCompletionItemProviderBase.TryGetAttributeInfo(node, out var prefixLocation, out var name, out var nameLocation, out var parameterName, out _);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
|
|
|
@ -287,7 +287,6 @@ namespace Microsoft.CodeAnalysis.Razor.Completion
|
|||
public void GetAttributeCompletions_BaseDirectiveAttributeAndParameterVariationsExist_ExcludesCompletion()
|
||||
{
|
||||
// Arrange
|
||||
var expectedCompletion = new RazorCompletionItem("@bind", "@bind", RazorCompletionItemKind.DirectiveAttribute);
|
||||
var attributeNames = new[]
|
||||
{
|
||||
"@bind",
|
||||
|
@ -306,7 +305,7 @@ namespace Microsoft.CodeAnalysis.Razor.Completion
|
|||
|
||||
private static void AssertContains(IReadOnlyList<RazorCompletionItem> completions, string insertText, string displayText, IReadOnlyCollection<string> commitCharacters)
|
||||
{
|
||||
displayText = displayText ?? insertText;
|
||||
displayText ??= insertText;
|
||||
|
||||
Assert.Contains(completions, completion =>
|
||||
{
|
||||
|
@ -319,7 +318,7 @@ namespace Microsoft.CodeAnalysis.Razor.Completion
|
|||
|
||||
private static void AssertDoesNotContain(IReadOnlyList<RazorCompletionItem> completions, string insertText, string displayText)
|
||||
{
|
||||
displayText = displayText ?? insertText;
|
||||
displayText ??= insertText;
|
||||
|
||||
Assert.DoesNotContain(completions, completion =>
|
||||
{
|
||||
|
|
|
@ -1323,7 +1323,7 @@ namespace Microsoft.VisualStudio.Editor.Razor
|
|||
IEnumerable<KeyValuePair<string, string>> attributes = null,
|
||||
string tagHelperPrefix = "")
|
||||
{
|
||||
attributes = attributes ?? Enumerable.Empty<KeyValuePair<string, string>>();
|
||||
attributes ??= Enumerable.Empty<KeyValuePair<string, string>>();
|
||||
var documentContext = TagHelperDocumentContext.Create(tagHelperPrefix, descriptors);
|
||||
var completionContext = new AttributeCompletionContext(
|
||||
documentContext,
|
||||
|
|
|
@ -567,8 +567,8 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
"ChangedRootNamespace");
|
||||
|
||||
// Force init
|
||||
var originalTagHelpers = original.TagHelpers;
|
||||
var originalProjectWorkspaceStateVersion = original.ConfigurationVersion;
|
||||
_ = original.TagHelpers;
|
||||
_ = original.ConfigurationVersion;
|
||||
|
||||
TagHelperResolver.TagHelpers = SomeTagHelpers;
|
||||
|
||||
|
@ -588,7 +588,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
.WithAddedHostDocument(Documents[1], DocumentState.EmptyLoader);
|
||||
|
||||
// Force init
|
||||
var originalProjectWorkspaceStateVersion = original.ProjectWorkspaceStateVersion;
|
||||
_ = original.ProjectWorkspaceStateVersion;
|
||||
|
||||
// Act
|
||||
var state = original.WithHostProject(HostProject);
|
||||
|
@ -778,8 +778,8 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
.WithAddedHostDocument(Documents[1], DocumentState.EmptyLoader);
|
||||
|
||||
// Force init
|
||||
var originalTagHelpers = original.TagHelpers;
|
||||
var originalProjectWorkspaceStateVersion = original.ProjectWorkspaceStateVersion;
|
||||
_ = original.TagHelpers;
|
||||
_ = original.ProjectWorkspaceStateVersion;
|
||||
|
||||
var changed = new ProjectWorkspaceState(original.TagHelpers, original.CSharpLanguageVersion);
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ namespace Microsoft.VisualStudio.Editor.Razor.Completion
|
|||
|
||||
// Assert
|
||||
var description = Assert.IsType<string>(descriptionObject);
|
||||
Assert.Equal(expectedDescription.Description, descriptionObject);
|
||||
Assert.Equal(expectedDescription.Description, description);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
@ -247,9 +247,9 @@ namespace Microsoft.VisualStudio.Editor.Razor
|
|||
VisualStudioRazorParser parser = null,
|
||||
BraceSmartIndenter smartIndenter = null)
|
||||
{
|
||||
documentTracker = documentTracker ?? Mock.Of<VisualStudioDocumentTracker>(MockBehavior.Strict);
|
||||
parser = parser ?? Mock.Of<VisualStudioRazorParser>(MockBehavior.Strict);
|
||||
smartIndenter = smartIndenter ?? Mock.Of<BraceSmartIndenter>(MockBehavior.Strict);
|
||||
documentTracker ??= Mock.Of<VisualStudioDocumentTracker>(MockBehavior.Strict);
|
||||
parser ??= Mock.Of<VisualStudioRazorParser>(MockBehavior.Strict);
|
||||
smartIndenter ??= Mock.Of<BraceSmartIndenter>(MockBehavior.Strict);
|
||||
|
||||
var documentTrackerFactory = Mock.Of<VisualStudioDocumentTrackerFactory>(f => f.Create(It.IsAny<ITextBuffer>()) == documentTracker, MockBehavior.Strict);
|
||||
var parserFactory = Mock.Of<VisualStudioRazorParserFactory>(f => f.Create(It.IsAny<VisualStudioDocumentTracker>()) == parser, MockBehavior.Strict);
|
||||
|
|
|
@ -337,7 +337,7 @@ namespace Microsoft.VisualStudio.Editor.Razor
|
|||
|
||||
private static RazorSyntaxTree GetSyntaxTree(StringTextSnapshot source, IEnumerable<DirectiveDescriptor> directives = null)
|
||||
{
|
||||
directives = directives ?? Enumerable.Empty<DirectiveDescriptor>();
|
||||
directives ??= Enumerable.Empty<DirectiveDescriptor>();
|
||||
var engine = RazorProjectEngine.Create(builder =>
|
||||
{
|
||||
foreach (var directive in directives)
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Microsoft.VisualStudio.Text
|
|||
var testArgs = new TestTextContentChangedEventArgs(before, after);
|
||||
|
||||
// Act
|
||||
var result = testArgs.TextChangeOccurred(out var changeInformation);
|
||||
var result = testArgs.TextChangeOccurred(out _);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
|
@ -35,7 +35,7 @@ namespace Microsoft.VisualStudio.Text
|
|||
var testArgs = new TestTextContentChangedEventArgs(before, after);
|
||||
|
||||
// Act
|
||||
var result = testArgs.TextChangeOccurred(out var changeInformation);
|
||||
var result = testArgs.TextChangeOccurred(out _);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
|
|
|
@ -172,7 +172,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
|
|||
|
||||
// Act
|
||||
store.Remove(projectFilePath);
|
||||
var result = store.TryGet(projectFilePath, out var configurationFilePath);
|
||||
var result = store.TryGet(projectFilePath, out _);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
|
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
|
||||
using Microsoft.VisualStudio.LanguageServer.Protocol;
|
||||
using Microsoft.VisualStudio.Text;
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
var workspaceAccessor = new TestWorkspaceAccessor(true, false);
|
||||
|
||||
// Act
|
||||
var result = workspaceAccessor.TryGetWorkspace(textBuffer, out var workspace);
|
||||
var result = workspaceAccessor.TryGetWorkspace(textBuffer, out _);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
|
@ -36,7 +36,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
var workspaceAccessor = new TestWorkspaceAccessor(false, true);
|
||||
|
||||
// Act
|
||||
var result = workspaceAccessor.TryGetWorkspace(textBuffer, out var workspace);
|
||||
var result = workspaceAccessor.TryGetWorkspace(textBuffer, out _);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
|
@ -50,7 +50,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
var workspaceAccessor = new TestWorkspaceAccessor(true, true);
|
||||
|
||||
// Act
|
||||
var result = workspaceAccessor.TryGetWorkspace(textBuffer, out var workspace);
|
||||
var result = workspaceAccessor.TryGetWorkspace(textBuffer, out _);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
|
|
|
@ -483,7 +483,6 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
ProjectManager.ProjectConfigurationChanged(HostProjectWithConfigurationChange);
|
||||
|
||||
// Assert
|
||||
var snapshot = ProjectManager.GetSnapshot(HostProjectWithConfigurationChange);
|
||||
Assert.Equal(ProjectChangeKind.ProjectChanged, ProjectManager.ListenersNotifiedOf);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче