未验证 提交 9ef36a8c 编写于 作者: S Sam Harwell 提交者: GitHub

Merge pull request #30866 from sharwell/code-style-changes

Code style changes
......@@ -36,7 +36,7 @@ public async Task DiagnosticAnalyzerDriverAllInOne()
{
var document = workspace.CurrentSolution.Projects.Single().Documents.Single();
AccessSupportedDiagnostics(analyzer);
await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(analyzer, document, new Text.TextSpan(0, document.GetTextAsync().Result.Length));
await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(analyzer, document, new TextSpan(0, document.GetTextAsync().Result.Length));
analyzer.VerifyAllAnalyzerMembersWereCalled();
analyzer.VerifyAnalyzeSymbolCalledForAllSymbolKinds();
var missingSyntaxNodes = new HashSet<SyntaxKind>();
......@@ -63,7 +63,7 @@ class C
using (var ideEngineWorkspace = TestWorkspace.CreateCSharp(source))
{
var ideEngineDocument = ideEngineWorkspace.CurrentSolution.Projects.Single().Documents.Single();
await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(ideEngineAnalyzer, ideEngineDocument, new Text.TextSpan(0, ideEngineDocument.GetTextAsync().Result.Length));
await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(ideEngineAnalyzer, ideEngineDocument, new TextSpan(0, ideEngineDocument.GetTextAsync().Result.Length));
foreach (var method in methodNames)
{
Assert.False(ideEngineAnalyzer.CallLog.Any(e => e.CallerName == method && e.MethodKind == MethodKind.DelegateInvoke && e.ReturnsVoid));
......@@ -97,7 +97,7 @@ public async Task DiagnosticAnalyzerDriverIsSafeAgainstAnalyzerExceptions()
{
var document = workspace.CurrentSolution.Projects.Single().Documents.Single();
await ThrowingDiagnosticAnalyzer<SyntaxKind>.VerifyAnalyzerEngineIsSafeAgainstExceptionsAsync(async analyzer =>
await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(analyzer, document, new Text.TextSpan(0, document.GetTextAsync().Result.Length), logAnalyzerExceptionAsDiagnostics: true));
await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(analyzer, document, new TextSpan(0, document.GetTextAsync().Result.Length), logAnalyzerExceptionAsDiagnostics: true));
}
}
......@@ -145,7 +145,7 @@ public async Task AnalyzerOptionsArePassedToAllAnalyzers()
var analyzer = new OptionsDiagnosticAnalyzer<SyntaxKind>(expectedOptions: options);
var sourceDocument = currentProject.Documents.Single();
await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(analyzer, sourceDocument, new Text.TextSpan(0, sourceDocument.GetTextAsync().Result.Length));
await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(analyzer, sourceDocument, new TextSpan(0, sourceDocument.GetTextAsync().Result.Length));
analyzer.VerifyAnalyzerOptions();
}
}
......@@ -175,7 +175,7 @@ public async Task AnalyzerCreatedAtCompilationLevelNeedNotBeCompilationAnalyzer(
using (var ideEngineWorkspace = TestWorkspace.CreateCSharp(source))
{
var ideEngineDocument = ideEngineWorkspace.CurrentSolution.Projects.Single().Documents.Single();
var diagnostics = await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(analyzer, ideEngineDocument, new Text.TextSpan(0, ideEngineDocument.GetTextAsync().Result.Length));
var diagnostics = await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(analyzer, ideEngineDocument, new TextSpan(0, ideEngineDocument.GetTextAsync().Result.Length));
var diagnosticsFromAnalyzer = diagnostics.Where(d => d.Id == "SyntaxDiagnostic");
......@@ -235,7 +235,7 @@ void F(int x = 0)
using (var ideEngineWorkspace = TestWorkspace.CreateCSharp(source))
{
var ideEngineDocument = ideEngineWorkspace.CurrentSolution.Projects.Single().Documents.Single();
var diagnostics = await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(analyzer, ideEngineDocument, new Text.TextSpan(0, ideEngineDocument.GetTextAsync().Result.Length));
var diagnostics = await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(analyzer, ideEngineDocument, new TextSpan(0, ideEngineDocument.GetTextAsync().Result.Length));
var diagnosticsFromAnalyzer = diagnostics.Where(d => d.Id == CodeBlockAnalyzerFactory.Descriptor.Id);
Assert.Equal(2, diagnosticsFromAnalyzer.Count());
}
......
using System;
// 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.ComponentModel.Composition;
using System.Linq;
......
......@@ -279,7 +279,7 @@ public override void Initialize(AnalysisContext context)
{
context.RegisterSyntaxTreeAction(c =>
{
c.ReportDiagnostic(Diagnostic.Create(_rule, Location.Create(c.Tree, new Text.TextSpan(0, 1))));
c.ReportDiagnostic(Diagnostic.Create(_rule, Location.Create(c.Tree, new TextSpan(0, 1))));
});
}
......
// 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 Microsoft.CodeAnalysis.Text;
using Moq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
using Roslyn.Test.Utilities;
namespace Microsoft.CodeAnalysis.Editor.UnitTests.Extensions
{
......
......@@ -64,7 +64,7 @@ public async Task TestCreateFromTemporaryStorage()
var textFactory = CreateMockTextFactoryService();
var temporaryStorageService = new TemporaryStorageServiceFactory.TemporaryStorageService(textFactory);
var text = Text.SourceText.From("Hello, World!");
var text = SourceText.From("Hello, World!");
// Create a temporary storage location
using (var temporaryStorage = temporaryStorageService.CreateTemporaryTextStorage(System.Threading.CancellationToken.None))
......@@ -87,7 +87,7 @@ public async Task TestCreateFromTemporaryStorageWithEncoding()
var textFactory = CreateMockTextFactoryService();
var temporaryStorageService = new TemporaryStorageServiceFactory.TemporaryStorageService(textFactory);
var text = Text.SourceText.From("Hello, World!", Encoding.ASCII);
var text = SourceText.From("Hello, World!", Encoding.ASCII);
// Create a temporary storage location
using (var temporaryStorage = temporaryStorageService.CreateTemporaryTextStorage(System.Threading.CancellationToken.None))
......
......@@ -3,6 +3,7 @@
Imports System.Collections.Immutable
Imports Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.QuickInfo
Imports Microsoft.CodeAnalysis.QuickInfo
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.VisualStudio.Imaging
Imports Microsoft.VisualStudio.Text
Imports Microsoft.VisualStudio.Text.Adornments
......@@ -17,7 +18,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
Public Async Sub BuildQuickInfoItem()
Dim codeAnalysisQuickInfoItem _
= QuickInfoItem.Create(New Text.TextSpan(0, 0), ImmutableArray.Create({"Method", "Public"}),
= QuickInfoItem.Create(New TextSpan(0, 0), ImmutableArray.Create({"Method", "Public"}),
ImmutableArray.Create _
({QuickInfoSection.Create("Description",
ImmutableArray.Create({
......
......@@ -9,14 +9,20 @@ namespace Microsoft.CodeAnalysis.CodeLens
/// </summary>
internal sealed class ReferenceLocationDescriptor
{
public int LineNumber { get; }
public int ColumnNumber { get; }
public Guid ProjectGuid { get; }
public Guid DocumentGuid { get; }
/// <summary>
/// Reference's line based on the document content
/// </summary>
public int LineNumber { get; }
/// <summary>
/// Reference's character based on the document content
/// </summary>
public int ColumnNumber { get; }
/// <summary>
/// Language of the reference location
/// </summary>
......@@ -67,7 +73,21 @@ internal sealed class ReferenceLocationDescriptor
/// </summary>
public string AfterReferenceText2 { get; }
public ReferenceLocationDescriptor(string longDescription, string language, Glyph? glyph, int lineNumber, int columnNumber, Guid projectGuid, Guid documentGuid, string referenceLineText, int referenceStart, int referenceLength, string beforeReferenceText1, string beforeReferenceText2, string afterReferenceText1, string afterReferenceText2)
public ReferenceLocationDescriptor(
string longDescription,
string language,
Glyph? glyph,
int lineNumber,
int columnNumber,
Guid projectGuid,
Guid documentGuid,
string referenceLineText,
int referenceStart,
int referenceLength,
string beforeReferenceText1,
string beforeReferenceText2,
string afterReferenceText1,
string afterReferenceText2)
{
LongDescription = longDescription;
Language = language;
......
......@@ -96,6 +96,7 @@ public interface IContext : IDisposable
/// you'll need a file watched (eventually) but it's not worth blocking yet.
/// </summary>
IFileWatchingToken EnqueueWatchingFile(string filePath);
void StopWatchingFile(IFileWatchingToken token);
}
......
......@@ -362,7 +362,7 @@ private bool TryGetProjectData(ProjectId projectId, out IVsHierarchy hierarchy,
project = null;
return
this.TryGetHierarchy(projectId, out hierarchy) &&
this.TryGetHierarchy(projectId, out hierarchy) &&
hierarchy.TryGetProject(out project);
}
......@@ -1040,7 +1040,7 @@ internal override Guid GetProjectGuid(ProjectId projectId)
internal override void SetDocumentContext(DocumentId documentId)
{
_foregroundObject.AssertIsForeground();
// Note: this method does not actually call into any workspace code here to change the workspace's context. The assumption is updating the running document table or
// IVsHierarchies will raise the appropriate events which we are subscribed to.
......@@ -1404,7 +1404,7 @@ private void ConvertProjectReferencesToMetadataReferences_NoLock(ProjectId proje
if (string.Equals(convertedReference.path, outputPath, StringComparison.OrdinalIgnoreCase) &&
convertedReference.projectReference.ProjectId == projectId)
{
var metadataReference =
var metadataReference =
CreateMetadataReference(
convertedReference.path,
new MetadataReferenceProperties(
......
......@@ -59,6 +59,7 @@ internal sealed class ContainedDocument : ForegroundThreadAffinitizedObject, IVi
});
private static ConcurrentDictionary<DocumentId, ContainedDocument> s_containedDocuments = new ConcurrentDictionary<DocumentId, ContainedDocument>();
public static ContainedDocument TryGetContainedDocument(DocumentId id)
{
ContainedDocument document;
......
......@@ -137,7 +137,7 @@ internal partial class ContainedLanguage<TPackage, TLanguageService>
// Get the ITextBuffer for the primary buffer
Marshal.ThrowExceptionForHR(bufferCoordinator.GetPrimaryBuffer(out var primaryTextLines));
DataBuffer = _editorAdaptersFactoryService.GetDataBuffer((IVsTextBuffer)primaryTextLines);
// Create our tagger
var bufferTagAggregatorFactory = ComponentModel.GetService<IBufferTagAggregatorFactoryService>();
_bufferTagAggregator = bufferTagAggregatorFactory.CreateTagAggregator<ITag>(SubjectBuffer);
......
......@@ -428,7 +428,7 @@ private SolutionState AddProject(ProjectId projectId, ProjectState projectState)
foreach (var newState in newStateMap)
{
foreach (var projectReference in newState.Value.ProjectReferences)
{
{
if (projectReference.ProjectId == projectId)
{
newDependencyGraph = newDependencyGraph.WithAdditionalProjectReferences(newState.Key, ImmutableArray.Create(projectId));
......@@ -436,7 +436,7 @@ private SolutionState AddProject(ProjectId projectId, ProjectState projectState)
}
}
}
var newTrackerMap = CreateCompilationTrackerMap(projectId, newDependencyGraph);
var newLinkedFilesMap = CreateLinkedFilesMapWithAddedProject(newStateMap[projectId]);
......@@ -1110,7 +1110,7 @@ public SolutionState AddDocuments(ImmutableArray<DocumentInfo> documentInfos)
var newProjectState = oldProject.AddDocuments(newDocumentStatesForProject);
newSolutionState = newSolutionState.ForkProject(newProjectState,
newSolutionState = newSolutionState.ForkProject(newProjectState,
CompilationTranslationAction.AddDocuments(newDocumentStatesForProject),
newLinkedFilesMap: CreateLinkedFilesMapWithAddedDocuments(newProjectState, documentInfosInProject.Select(d => d.Id)));
}
......
......@@ -16,7 +16,6 @@ namespace Microsoft.CodeAnalysis
internal partial class TextDocumentState
{
protected readonly SolutionServices solutionServices;
private readonly DocumentInfo.DocumentAttributes attributes;
/// <summary>
/// A direct reference to our source text. This is only kept around in specialized scenarios.
......@@ -46,38 +45,36 @@ internal partial class TextDocumentState
ValueSource<DocumentStateChecksums> lazyChecksums)
{
this.solutionServices = solutionServices;
this.attributes = attributes;
this.sourceTextOpt = sourceTextOpt;
this.textAndVersionSource = textAndVersionSource;
Attributes = attributes;
// for now, let it re-calculate if anything changed.
// TODO: optimize this so that we only re-calcuate checksums that are actually changed
_lazyChecksums = new AsyncLazy<DocumentStateChecksums>(ComputeChecksumsAsync, cacheResult: true);
}
public DocumentInfo.DocumentAttributes Attributes { get; }
public DocumentId Id
{
get { return this.attributes.Id; }
get { return Attributes.Id; }
}
public string FilePath
{
get { return this.attributes.FilePath; }
}
public DocumentInfo.DocumentAttributes Attributes
{
get { return this.attributes; }
get { return Attributes.FilePath; }
}
public IReadOnlyList<string> Folders
{
get { return this.attributes.Folders; }
get { return Attributes.Folders; }
}
public string Name
{
get { return this.attributes.Name; }
get { return this.Attributes.Name; }
}
public static TextDocumentState Create(DocumentInfo info, SolutionServices services)
......@@ -323,7 +320,7 @@ public TextDocumentState UpdateText(TextAndVersion newTextAndVersion, Preservati
return new TextDocumentState(
this.solutionServices,
this.attributes,
this.Attributes,
sourceTextOpt: null,
textAndVersionSource: newTextSource,
lazyChecksums: null);
......@@ -357,7 +354,7 @@ public TextDocumentState UpdateText(TextLoader loader, PreservationMode mode)
return new TextDocumentState(
this.solutionServices,
this.attributes,
this.Attributes,
sourceTextOpt: null,
textAndVersionSource: newTextSource,
lazyChecksums: null);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册