Move shared editor test helpers into Test.Common.Tooling

This commit is contained in:
Dustin Campbell 2023-11-08 10:20:00 -08:00
Родитель 5327a1e90a
Коммит acc30debae
75 изменённых файлов: 138 добавлений и 408 удалений

Просмотреть файл

@ -40,7 +40,6 @@
"src\\Razor\\test\\Microsoft.AspNetCore.Razor.Test.MvcShim\\Microsoft.AspNetCore.Razor.Test.MvcShim.csproj",
"src\\Razor\\test\\Microsoft.CodeAnalysis.Razor.Workspaces.Test\\Microsoft.CodeAnalysis.Razor.Workspaces.Test.csproj",
"src\\Razor\\test\\Microsoft.CodeAnalysis.Remote.Razor.Test\\Microsoft.CodeAnalysis.Remote.Razor.Test.csproj",
"src\\Razor\\test\\Microsoft.VisualStudio.Editor.Razor.Test.Common\\Microsoft.VisualStudio.Editor.Razor.Test.Common.csproj",
"src\\Razor\\test\\Microsoft.VisualStudio.Editor.Razor.Test\\Microsoft.VisualStudio.Editor.Razor.Test.csproj",
"src\\Razor\\test\\Microsoft.VisualStudio.LanguageServer.ContainedLanguage.Test.Common\\Microsoft.VisualStudio.LanguageServer.ContainedLanguage.Test.Common.csproj",
"src\\Razor\\test\\Microsoft.VisualStudio.LanguageServer.ContainedLanguage.Test\\Microsoft.VisualStudio.LanguageServer.ContainedLanguage.Test.csproj",

Просмотреть файл

@ -30,8 +30,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.Edit
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.Editor.Razor.Test", "src\Razor\test\Microsoft.VisualStudio.Editor.Razor.Test\Microsoft.VisualStudio.Editor.Razor.Test.csproj", "{AA888DB9-340E-4E06-A2A4-25BFEE1AC2B7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.Editor.Razor.Test.Common", "src\Razor\test\Microsoft.VisualStudio.Editor.Razor.Test.Common\Microsoft.VisualStudio.Editor.Razor.Test.Common.csproj", "{FC684D4F-D23C-407C-9C68-E10EF3B38560}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Microbenchmarks", "src\Razor\benchmarks\Microsoft.AspNetCore.Razor.Microbenchmarks\Microsoft.AspNetCore.Razor.Microbenchmarks.csproj", "{6205467F-E381-4C42-AEEC-763BD62B3D5E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{C2C98051-0F39-47F2-80B6-E72B29159F2C}"
@ -177,7 +175,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Test.Common", "src\Shared\Microsoft.AspNetCore.Razor.Test.Common\Microsoft.AspNetCore.Razor.Test.Common.csproj", "{64A72A33-38B4-4C23-9E12-D7FEBD673FB7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Razor.Language.Legacy.Test", "src\Compiler\Microsoft.AspNetCore.Razor.Language\legacyTest\Microsoft.AspNetCore.Razor.Language.Legacy.Test.csproj", "{C504C2D7-8313-46D8-A159-7EB79047C09C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Language.Legacy.Test", "src\Compiler\Microsoft.AspNetCore.Razor.Language\legacyTest\Microsoft.AspNetCore.Razor.Language.Legacy.Test.csproj", "{C504C2D7-8313-46D8-A159-7EB79047C09C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -267,14 +265,6 @@ Global
{AA888DB9-340E-4E06-A2A4-25BFEE1AC2B7}.Release|Any CPU.Build.0 = Release|Any CPU
{AA888DB9-340E-4E06-A2A4-25BFEE1AC2B7}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
{AA888DB9-340E-4E06-A2A4-25BFEE1AC2B7}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
{FC684D4F-D23C-407C-9C68-E10EF3B38560}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FC684D4F-D23C-407C-9C68-E10EF3B38560}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC684D4F-D23C-407C-9C68-E10EF3B38560}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
{FC684D4F-D23C-407C-9C68-E10EF3B38560}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU
{FC684D4F-D23C-407C-9C68-E10EF3B38560}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC684D4F-D23C-407C-9C68-E10EF3B38560}.Release|Any CPU.Build.0 = Release|Any CPU
{FC684D4F-D23C-407C-9C68-E10EF3B38560}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
{FC684D4F-D23C-407C-9C68-E10EF3B38560}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
{6205467F-E381-4C42-AEEC-763BD62B3D5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6205467F-E381-4C42-AEEC-763BD62B3D5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6205467F-E381-4C42-AEEC-763BD62B3D5E}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
@ -729,7 +719,8 @@ Global
{64A72A33-38B4-4C23-9E12-D7FEBD673FB7}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU
{64A72A33-38B4-4C23-9E12-D7FEBD673FB7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{64A72A33-38B4-4C23-9E12-D7FEBD673FB7}.Release|Any CPU.Build.0 = Release|Any CPU
<<<<<<< HEAD
{64A72A33-38B4-4C23-9E12-D7FEBD673FB7}.ReleaseNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
{64A72A33-38B4-4C23-9E12-D7FEBD673FB7}.ReleaseNoVSIX|Any CPU.Build.0 = Debug|Any CPU
{C504C2D7-8313-46D8-A159-7EB79047C09C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C504C2D7-8313-46D8-A159-7EB79047C09C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C504C2D7-8313-46D8-A159-7EB79047C09C}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
@ -738,10 +729,6 @@ Global
{C504C2D7-8313-46D8-A159-7EB79047C09C}.Release|Any CPU.Build.0 = Release|Any CPU
{C504C2D7-8313-46D8-A159-7EB79047C09C}.ReleaseNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
{C504C2D7-8313-46D8-A159-7EB79047C09C}.ReleaseNoVSIX|Any CPU.Build.0 = Debug|Any CPU
=======
{64A72A33-38B4-4C23-9E12-D7FEBD673FB7}.ReleaseNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
{64A72A33-38B4-4C23-9E12-D7FEBD673FB7}.ReleaseNoVSIX|Any CPU.Build.0 = Debug|Any CPU
>>>>>>> 55d8686c6 (Move shared workspaces test helpers into Test.Common.Tooling)
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -757,7 +744,6 @@ Global
{AC5CA24B-B81E-4B20-B193-2E3983B1896C} = {92463391-81BE-462B-AC3C-78C6C760741F}
{0BCDE75A-A438-46C7-95E9-391F029D07C5} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
{AA888DB9-340E-4E06-A2A4-25BFEE1AC2B7} = {92463391-81BE-462B-AC3C-78C6C760741F}
{FC684D4F-D23C-407C-9C68-E10EF3B38560} = {92463391-81BE-462B-AC3C-78C6C760741F}
{6205467F-E381-4C42-AEEC-763BD62B3D5E} = {C2C98051-0F39-47F2-80B6-E72B29159F2C}
{72E89155-86C7-454E-BDD9-39F497F2F61B} = {92463391-81BE-462B-AC3C-78C6C760741F}
{D87E5501-B832-46B6-ACD3-EC989E3D14ED} = {92463391-81BE-462B-AC3C-78C6C760741F}

Просмотреть файл

@ -154,6 +154,7 @@
<Tooling_MicrosoftVisualStudioLanguageServicesPackageVersion>$(MicrosoftVisualStudioLanguageServicesPackageVersion)</Tooling_MicrosoftVisualStudioLanguageServicesPackageVersion>
<XunitAnalyzersPackageVersion>0.10.0</XunitAnalyzersPackageVersion>
<XunitCombinatorialPackageVersion>1.4.1</XunitCombinatorialPackageVersion>
<XunitStaFactVersion>1.1.11</XunitStaFactVersion>
<XunitVersion>2.4.2</XunitVersion>
<XunitExtensibilityExecutionPackageVersion>$(XunitVersion)</XunitExtensibilityExecutionPackageVersion>
<!-- Temporary hack to workaround package restrictions for dev17 -->

Просмотреть файл

@ -14,4 +14,11 @@
OutputItemType="Analyzer" />
</ItemGroup>
<!-- Only include .NET Framework files when building for .NET Framework -->
<ItemGroup Condition="'$(TargetFramework)' != '$(DefaultNetFxTargetFramework)'">
<Compile Remove="**\*.NetFX.cs" />
<Compile Remove="**\NetFx\**\*.*" />
<Compile Remove="**\*_NetFx\**\*.*" />
</ItemGroup>
</Project>

Просмотреть файл

@ -6,6 +6,7 @@ using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.ExternalAccess.LegacyEditor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.LanguageServer, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.LanguageServer.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Test.Common.Tooling, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Remote.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServerClient.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServerClient.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]

Просмотреть файл

@ -17,7 +17,7 @@ internal abstract class TelemetryReporter : ITelemetryReporter
{
protected ImmutableArray<TelemetrySession> TelemetrySessions { get; set; }
protected TelemetryReporter(ImmutableArray<TelemetrySession> telemetrySessions)
protected TelemetryReporter(ImmutableArray<TelemetrySession> telemetrySessions = default)
{
// Get the DefaultSession for telemetry. This is set by VS with
// TelemetryService.SetDefaultSession and provides the correct

Просмотреть файл

@ -1,13 +1,11 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using Microsoft.AspNetCore.Razor.Language.Legacy;
using Microsoft.CodeAnalysis.Razor;
using Xunit.Abstractions;
namespace Xunit;
namespace Microsoft.AspNetCore.Razor.Test.Common.Editor;
public abstract class ProjectSnapshotManagerDispatcherTestBase : ToolingParserTestBase
{

Просмотреть файл

@ -1,13 +1,11 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
using Microsoft.CodeAnalysis.Razor;
using Xunit.Abstractions;
namespace Xunit;
namespace Microsoft.AspNetCore.Razor.Test.Common.Editor;
public abstract class ProjectSnapshotManagerDispatcherWorkspaceTestBase : WorkspaceTestBase
{

Просмотреть файл

@ -1,27 +1,20 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System.IO;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Text;
namespace Microsoft.VisualStudio.Text;
namespace Microsoft.AspNetCore.Razor.Test.Common.Editor;
public class StringTextImage : ITextImage
public class StringTextImage(string text) : ITextImage
{
private readonly SourceText _sourceText;
private readonly string _text;
public StringTextImage(string text)
{
_text = text;
_sourceText = SourceText.From(text);
}
private readonly SourceText _sourceText = SourceText.From(text);
private readonly string _text = text;
public char this[int position] => _text[position];
public ITextImageVersion Version => null;
public ITextImageVersion Version => null!;
public int Length => _text.Length;

Просмотреть файл

@ -1,33 +1,33 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Utilities;
namespace Microsoft.VisualStudio.Text;
namespace Microsoft.AspNetCore.Razor.Test.Common.Editor;
public class StringTextSnapshot : ITextSnapshot2
{
private readonly List<ITextSnapshotLine> _lines;
private ITextBuffer _textBuffer;
private ITextBuffer? _textBuffer;
public static readonly StringTextSnapshot Empty = new(string.Empty);
public StringTextSnapshot(string content) : this(content, versionNumber: 0)
public StringTextSnapshot(string content)
: this(content, versionNumber: 0)
{
}
public StringTextSnapshot(string content, int versionNumber)
{
Content = content;
_lines = new List<ITextSnapshotLine>();
_lines = [];
var start = 0;
var delimiterIndex = 0;
@ -58,6 +58,8 @@ public class StringTextSnapshot : ITextSnapshot2
Version = new TextVersion(versionNumber);
}
Version.AssumeNotNull();
}
public string Content { get; }
@ -68,17 +70,17 @@ public class StringTextSnapshot : ITextSnapshot2
public int Length => Content.Length;
public ITextBuffer TextBuffer
public ITextBuffer? TextBuffer
{
get => _textBuffer;
set
{
_textBuffer = value;
ContentType = _textBuffer.ContentType;
ContentType = _textBuffer?.ContentType;
}
}
public IContentType ContentType { get; private set; }
public IContentType? ContentType { get; private set; }
public int LineCount => _lines.Count;
@ -144,16 +146,11 @@ public class StringTextSnapshot : ITextSnapshot2
throw new NotImplementedException();
}
private class TextVersion : ITextVersion
private class TextVersion(int versionNumber) : ITextVersion
{
public TextVersion(int versionNumber)
{
VersionNumber = versionNumber;
}
public INormalizedTextChangeCollection Changes { get; } = new TextChangeCollection();
public int VersionNumber { get; }
public int VersionNumber { get; } = versionNumber;
public ITextVersion Next => throw new NotImplementedException();
@ -163,34 +160,31 @@ public class StringTextSnapshot : ITextSnapshot2
public int ReiteratedVersionNumber => throw new NotImplementedException();
public ITrackingSpan CreateCustomTrackingSpan(VisualStudio.Text.Span span, TrackingFidelityMode trackingFidelity, object customState, CustomTrackToVersion behavior) => throw new NotImplementedException();
public ITrackingSpan CreateCustomTrackingSpan(Span span, TrackingFidelityMode trackingFidelity, object customState, CustomTrackToVersion behavior) => throw new NotImplementedException();
public ITrackingPoint CreateTrackingPoint(int position, PointTrackingMode trackingMode) => throw new NotImplementedException();
public ITrackingPoint CreateTrackingPoint(int position, PointTrackingMode trackingMode, TrackingFidelityMode trackingFidelity) => throw new NotImplementedException();
public ITrackingSpan CreateTrackingSpan(VisualStudio.Text.Span span, SpanTrackingMode trackingMode) => throw new NotImplementedException();
public ITrackingSpan CreateTrackingSpan(Span span, SpanTrackingMode trackingMode) => throw new NotImplementedException();
public ITrackingSpan CreateTrackingSpan(VisualStudio.Text.Span span, SpanTrackingMode trackingMode, TrackingFidelityMode trackingFidelity) => throw new NotImplementedException();
public ITrackingSpan CreateTrackingSpan(Span span, SpanTrackingMode trackingMode, TrackingFidelityMode trackingFidelity) => throw new NotImplementedException();
public ITrackingSpan CreateTrackingSpan(int start, int length, SpanTrackingMode trackingMode) => throw new NotImplementedException();
public ITrackingSpan CreateTrackingSpan(int start, int length, SpanTrackingMode trackingMode, TrackingFidelityMode trackingFidelity) => throw new NotImplementedException();
#pragma warning disable CS8644 // Type does not implement interface member. Nullability of reference types in interface implemented by the base type doesn't match.
private class TextChangeCollection : List<ITextChange>, INormalizedTextChangeCollection
#pragma warning restore CS8644
{
public bool IncludesLineChanges => false;
}
}
private class SnapshotTrackingPoint : ITrackingPoint
private class SnapshotTrackingPoint(int position) : ITrackingPoint
{
private readonly int _position;
public SnapshotTrackingPoint(int position)
{
_position = position;
}
private readonly int _position = position;
public ITextBuffer TextBuffer => throw new NotImplementedException();
@ -229,7 +223,7 @@ public class StringTextSnapshot : ITextSnapshot2
Start = new SnapshotPoint(owner, start);
End = new SnapshotPoint(owner, start + _content.Length);
Snapshot = owner;
LineNumber = (owner as StringTextSnapshot)._lines.Count;
LineNumber = (owner as StringTextSnapshot)?._lines.Count ?? 0;
}
public ITextSnapshot Snapshot { get; }

Просмотреть файл

@ -1,12 +1,10 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.VisualStudio.Text;
namespace Microsoft.VisualStudio.Test;
namespace Microsoft.AspNetCore.Razor.Test.Common.Editor;
public class TestEdit
{

Просмотреть файл

@ -1,14 +1,11 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.Utilities;
namespace Microsoft.VisualStudio.Test;
namespace Microsoft.AspNetCore.Razor.Test.Common.Editor;
public class TestInertContentType : IContentType
{
@ -18,7 +15,7 @@ public class TestInertContentType : IContentType
public string DisplayName => TypeName;
public IEnumerable<IContentType> BaseTypes => Enumerable.Empty<IContentType>();
public IEnumerable<IContentType> BaseTypes => Array.Empty<IContentType>();
public bool IsOfType(string type) => string.Equals(type, TypeName, StringComparison.OrdinalIgnoreCase);
}

Просмотреть файл

@ -1,16 +1,15 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Razor;
using Xunit;
namespace Microsoft.CodeAnalysis.Razor;
namespace Microsoft.AspNetCore.Razor.Test.Common.Editor;
internal class TestProjectSnapshotManagerDispatcher : ProjectSnapshotManagerDispatcher
{

Просмотреть файл

@ -7,9 +7,9 @@ using Microsoft.VisualStudio.Telemetry;
namespace Microsoft.VisualStudio.Editor.Razor.Test.Shared;
internal class TestTelemetryReporter() : TelemetryReporter(default)
internal class TestTelemetryReporter() : TelemetryReporter()
{
public List<TelemetryEvent> Events { get; } = new();
public List<TelemetryEvent> Events { get; } = [];
protected override void Report(TelemetryEvent telemetryEvent)
{

Просмотреть файл

@ -1,20 +1,18 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Utilities;
namespace Microsoft.VisualStudio.Test;
namespace Microsoft.AspNetCore.Razor.Test.Common.Editor;
public class TestTextBuffer : ITextBuffer
{
private readonly List<EventHandler<TextContentChangedEventArgs>> _attachedChangedEvents;
public TestTextBuffer(ITextSnapshot initialSnapshot, IContentType contentType = null)
public TestTextBuffer(ITextSnapshot initialSnapshot, IContentType? contentType = null)
{
ChangeContentType(contentType ?? TestInertContentType.Instance, editTag: null);
@ -24,7 +22,7 @@ public class TestTextBuffer : ITextBuffer
testSnapshot.TextBuffer = this;
}
_attachedChangedEvents = new List<EventHandler<TextContentChangedEventArgs>>();
_attachedChangedEvents = [];
ReadOnlyRegionsChanged += (sender, args) => { };
ChangedLowPriority += (sender, args) => { };
@ -47,13 +45,13 @@ public class TestTextBuffer : ITextBuffer
return;
}
var args = new TextContentChangedEventArgs(edits[0].OldSnapshot, edits[edits.Length - 1].NewSnapshot, new EditOptions(), null);
var args = new TextContentChangedEventArgs(edits[0].OldSnapshot, edits[^1].NewSnapshot, new EditOptions(), null);
foreach (var edit in edits)
{
args.Changes.Add(new TestTextChange(edit.Change));
}
CurrentSnapshot = edits[edits.Length - 1].NewSnapshot;
CurrentSnapshot = edits[^1].NewSnapshot;
if (CurrentSnapshot is StringTextSnapshot testSnapshot)
{
testSnapshot.TextBuffer = this;
@ -64,12 +62,12 @@ public class TestTextBuffer : ITextBuffer
changedEvent.Invoke(this, args);
}
PostChanged?.Invoke(this, null);
PostChanged?.Invoke(this, null!);
ReadOnlyRegionsChanged?.Invoke(this, null);
ChangedLowPriority?.Invoke(this, null);
ChangedHighPriority?.Invoke(this, null);
Changing?.Invoke(this, null);
ReadOnlyRegionsChanged?.Invoke(this, null!);
ChangedLowPriority?.Invoke(this, null!);
ChangedHighPriority?.Invoke(this, null!);
Changing?.Invoke(this, null!);
}
public IReadOnlyList<EventHandler<TextContentChangedEventArgs>> AttachedChangedEvents => _attachedChangedEvents;
@ -100,11 +98,12 @@ public class TestTextBuffer : ITextBuffer
public bool EditInProgress => throw new NotImplementedException();
public IContentType ContentType { get; private set; }
public IContentType? ContentType { get; private set; }
public ITextEdit CreateEdit() => new BufferEdit(this);
public void ChangeContentType(IContentType newContentType, object editTag){
public void ChangeContentType(IContentType newContentType, object? editTag)
{
ContentType = newContentType;
if (CurrentSnapshot is StringTextSnapshot oldStringTextSnapshot)
@ -116,7 +115,7 @@ public class TestTextBuffer : ITextBuffer
CurrentSnapshot = newStringTextSnapshot;
}
ContentTypeChanged?.Invoke(this, null);
ContentTypeChanged?.Invoke(this, null!);
}
public bool CheckEditAccess() => throw new NotImplementedException();
@ -139,7 +138,7 @@ public class TestTextBuffer : ITextBuffer
public bool IsReadOnly(Span span, bool isEdit) => throw new NotImplementedException();
public ITextSnapshot Replace(Text.Span replaceSpan, string replaceWith) => throw new NotImplementedException();
public ITextSnapshot Replace(Span replaceSpan, string replaceWith) => throw new NotImplementedException();
public void TakeThreadOwnership() => throw new NotImplementedException();

Просмотреть файл

@ -1,17 +1,16 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.VisualStudio.Text;
namespace Microsoft.VisualStudio.Test;
namespace Microsoft.AspNetCore.Razor.Test.Common.Editor;
public class TestTextChange : ITextChange
{
public TestTextChange(TestEdit edit) : this(edit.Change)
public TestTextChange(TestEdit edit)
: this(edit.Change)
{
}

Просмотреть файл

@ -33,6 +33,7 @@
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Razor.LanguageServer\Microsoft.AspNetCore.Razor.LanguageServer.csproj" />
<ProjectReference Include="..\..\..\Compiler\Microsoft.AspNetCore.Razor.Language\src\Microsoft.CodeAnalysis.Razor.Compiler.Language.csproj" />
<ProjectReference Include="..\..\..\Compiler\Microsoft.CodeAnalysis.Razor\src\Microsoft.CodeAnalysis.Razor.Compiler.CSharp.csproj" />
<ProjectReference Include="..\..\src\Microsoft.VisualStudio.Editor.Razor\Microsoft.VisualStudio.Editor.Razor.csproj" />
</ItemGroup>
<ItemGroup>
@ -48,10 +49,13 @@
<PackageReference Include="xunit.analyzers" Version="$(XunitAnalyzersPackageVersion)" />
<PackageReference Include="xunit.extensibility.execution" Version="$(XunitExtensibilityExecutionPackageVersion)" />
<PackageReference Include="Xunit.Combinatorial" Version="$(XunitCombinatorialPackageVersion)" />
<PackageReference Include="Xunit.StaFact" Version="$(XunitStaFactVersion)" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == '$(DefaultNetFxTargetFramework)'">
<Reference Include="WindowsBase" />
<PackageReference Include="Microsoft.VisualStudio.Language.Intellisense" Version="$(MicrosoftVisualStudioLanguageIntellisensePackageVersion)" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -16,8 +16,4 @@
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Test.MvcShim\Microsoft.AspNetCore.Razor.Test.MvcShim.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="$(SystemRuntimeInteropServicesRuntimePackageVersion)" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,34 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System.Collections.Generic;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis;
using System.Threading;
namespace Microsoft.VisualStudio.Editor.Razor.Test;
internal class TestProjectWorkspaceStateGenerator : ProjectWorkspaceStateGenerator
{
private readonly List<(Project workspaceProject, IProjectSnapshot projectSnapshot)> _updates;
public TestProjectWorkspaceStateGenerator()
{
_updates = new List<(Project workspaceProject, IProjectSnapshot projectSnapshot)>();
}
public IReadOnlyList<(Project workspaceProject, IProjectSnapshot projectSnapshot)> UpdateQueue => _updates;
public override void Initialize(ProjectSnapshotManagerBase projectManager)
{
}
public override void Update(Project workspaceProject, IProjectSnapshot projectSnapshot, CancellationToken cancellationToken)
{
var update = (workspaceProject, projectSnapshot);
_updates.Add(update);
}
}

Просмотреть файл

@ -1,16 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using Xunit.Sdk;
namespace Xunit;
// Similar to WpfFactAttribute https://github.com/xunit/samples.xunit/blob/969d9f7e887836f01a6c525324bf3db55658c28f/STAExamples/WpfFactAttribute.cs
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
[XunitTestCaseDiscoverer("Xunit." + nameof(UIFactDiscoverer), "Microsoft.VisualStudio.Editor.Razor.Test.Common")]
public class UIFactAttribute : FactAttribute
{
}

Просмотреть файл

@ -1,22 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using Xunit.Abstractions;
using Xunit.Sdk;
namespace Xunit;
internal class UIFactDiscoverer : FactDiscoverer
{
public UIFactDiscoverer(IMessageSink diagnosticMessageSink)
: base(diagnosticMessageSink)
{
}
protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
return new UITestCase(DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod);
}
}

Просмотреть файл

@ -1,87 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.ComponentModel;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Threading;
using Xunit.Abstractions;
using Xunit.Sdk;
namespace Xunit;
internal class UITestCase : XunitTestCase
{
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("Called by the de-serializer", error: true)]
public UITestCase()
{
}
public UITestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, object[] testMethodArguments = null)
: base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments)
{
}
public override Task<RunSummary> RunAsync(
IMessageSink diagnosticMessageSink,
IMessageBus messageBus,
object[] constructorArguments,
ExceptionAggregator aggregator,
CancellationTokenSource cancellationTokenSource)
{
var tcs = new TaskCompletionSource<RunSummary>();
var thread = new Thread(() =>
{
try
{
SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext());
var worker = base.RunAsync(diagnosticMessageSink, messageBus, constructorArguments, aggregator, cancellationTokenSource);
Exception caught = null;
var frame = new DispatcherFrame();
_ = Task.Run(async () =>
{
try
{
#pragma warning disable VSTHRD003 // Avoid awaiting foreign Tasks
await worker;
#pragma warning restore VSTHRD003 // Avoid awaiting foreign Tasks
}
catch (Exception ex)
{
caught = ex;
}
finally
{
frame.Continue = false;
}
});
Dispatcher.PushFrame(frame);
if (caught is null)
{
tcs.SetResult(worker.Result);
}
else
{
tcs.SetException(caught);
}
}
catch (Exception e)
{
tcs.SetException(e);
}
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
return tcs.Task;
}
}

Просмотреть файл

@ -1,16 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using Xunit.Sdk;
namespace Xunit;
// Similar to WpfTheoryAttribute https://github.com/xunit/samples.xunit/blob/969d9f7e887836f01a6c525324bf3db55658c28f/STAExamples/WpfTheoryAttribute.cs
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
[XunitTestCaseDiscoverer("Xunit." + nameof(UITheoryDiscoverer), "Microsoft.VisualStudio.Editor.Razor.Test.Common")]
internal class UITheoryAttribute : TheoryAttribute
{
}

Просмотреть файл

@ -1,26 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System.Collections.Generic;
using Xunit.Abstractions;
using Xunit.Sdk;
namespace Xunit;
internal class UITheoryDiscoverer : TheoryDiscoverer
{
public UITheoryDiscoverer(IMessageSink diagnosticMessageSink)
: base(diagnosticMessageSink)
{
}
protected override IEnumerable<IXunitTestCase> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow)
{
return new[]
{
new UITestCase(DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, dataRow),
};
}
}

Просмотреть файл

@ -6,7 +6,7 @@
using System;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Extensions;
using Microsoft.VisualStudio.Test;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.VisualStudio.Text;
using Moq;
using Xunit;
@ -14,13 +14,8 @@ using Xunit.Abstractions;
namespace Microsoft.VisualStudio.Editor.Razor;
public class BraceSmartIndenterIntegrationTest : BraceSmartIndenterTestBase
public class BraceSmartIndenterIntegrationTest(ITestOutputHelper testOutput) : BraceSmartIndenterTestBase(testOutput)
{
public BraceSmartIndenterIntegrationTest(ITestOutputHelper testOutput)
: base(testOutput)
{
}
[UIFact]
public void TextBuffer_OnPostChanged_IndentsInbetweenBraces_BaseIndentation()
{

Просмотреть файл

@ -9,7 +9,7 @@ using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Extensions;
using Microsoft.AspNetCore.Razor.Language.Legacy;
using Microsoft.AspNetCore.Razor.Language.Syntax;
using Microsoft.VisualStudio.Test;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Operations;

Просмотреть файл

@ -2,12 +2,11 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using Microsoft.VisualStudio.Test;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Operations;
using Moq;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.VisualStudio.Editor.Razor;

Просмотреть файл

@ -5,21 +5,16 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.CodeAnalysis.Razor.Editor;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.VisualStudio.Editor.Razor;
public class ClientSettingsManagerTest : ProjectSnapshotManagerDispatcherTestBase
public class ClientSettingsManagerTest(ITestOutputHelper testOutput) : ProjectSnapshotManagerDispatcherTestBase(testOutput)
{
private readonly IEnumerable<ClientSettingsChangedTrigger> _editorSettingsChangeTriggers;
public ClientSettingsManagerTest(ITestOutputHelper testOutput)
: base(testOutput)
{
_editorSettingsChangeTriggers = Array.Empty<ClientSettingsChangedTrigger>();
}
private readonly IEnumerable<ClientSettingsChangedTrigger> _editorSettingsChangeTriggers = Array.Empty<ClientSettingsChangedTrigger>();
[Fact]
public void ChangeTriggersGetInitialized()

Просмотреть файл

@ -4,6 +4,7 @@
#nullable disable
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.CodeAnalysis.Razor.Completion;
using Microsoft.CodeAnalysis.Razor.Tooltip;
using Microsoft.VisualStudio.Language.Intellisense;

Просмотреть файл

@ -5,6 +5,7 @@
using System;
using System.Collections.ObjectModel;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.Completion;
using Microsoft.VisualStudio.Text;

Просмотреть файл

@ -12,6 +12,7 @@ using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Extensions;
using Microsoft.AspNetCore.Razor.Language.Legacy;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.CodeAnalysis.Razor.Completion;
using Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion;
using Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion.Data;

Просмотреть файл

@ -6,6 +6,7 @@
using System.IO;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Moq;
using Xunit;

Просмотреть файл

@ -7,6 +7,7 @@ using System;
using System.IO;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.VisualStudio.Editor.Razor.Documents;
using Moq;

Просмотреть файл

@ -12,6 +12,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.AspNetCore.Razor.Test.Common.ProjectSystem;
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
using Microsoft.CodeAnalysis.Host;

Просмотреть файл

@ -6,6 +6,7 @@
using System.Collections.Immutable;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Razor;

Просмотреть файл

@ -6,8 +6,7 @@ using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Syntax;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.VisualStudio.Test;
using Microsoft.VisualStudio.Text;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Xunit;
using Xunit.Abstractions;

Просмотреть файл

@ -7,6 +7,7 @@ using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.AspNetCore.Razor.Test.Common.ProjectSystem;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Host;

Просмотреть файл

@ -11,11 +11,11 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Razor.Extensions;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Syntax;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.AspNetCore.Razor.Test.Common.ProjectSystem;
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.VisualStudio.Test;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Moq;

Просмотреть файл

@ -7,12 +7,11 @@ using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.VisualStudio.Test;
using Microsoft.VisualStudio.Text;
using Moq;
using Xunit;
using Xunit.Abstractions;

Просмотреть файл

@ -3,6 +3,7 @@
#nullable disable
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.CodeAnalysis.Razor.Editor;
using Moq;
using Xunit;

Просмотреть файл

@ -6,9 +6,9 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.VisualStudio.Test;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Threading;
using Xunit;

Просмотреть файл

@ -3,13 +3,12 @@
using System;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.AspNetCore.Razor.Test.Common.ProjectSystem;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Test;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Threading;
using Moq;
using Xunit;

Просмотреть файл

@ -4,11 +4,10 @@
#nullable disable
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Test;
using Microsoft.VisualStudio.Text;
using Moq;
using Xunit;
using Xunit.Abstractions;

Просмотреть файл

@ -21,10 +21,15 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.VisualStudio.Editor.Razor.Test.Common\Microsoft.VisualStudio.Editor.Razor.Test.Common.csproj" />
<ProjectReference Include="..\..\..\Compiler\Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X\src\Microsoft.CodeAnalysis.Razor.Compiler.Mvc.Version1_X.csproj" />
<ProjectReference Include="..\..\..\Compiler\Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X\src\Microsoft.CodeAnalysis.Razor.Compiler.Mvc.Version2_X.csproj" />
<ProjectReference Include="..\..\..\Compiler\Microsoft.AspNetCore.Mvc.Razor.Extensions\src\Microsoft.CodeAnalysis.Razor.Compiler.Mvc.csproj" />
<ProjectReference Include="..\..\src\Microsoft.VisualStudio.Editor.Razor\Microsoft.VisualStudio.Editor.Razor.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Test.Common.Tooling\Microsoft.AspNetCore.Razor.Test.Common.Tooling.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Shared\" />
</ItemGroup>
</Project>

Просмотреть файл

@ -7,23 +7,17 @@ using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc.Razor.Extensions;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Legacy;
using Microsoft.VisualStudio.Test;
using Microsoft.VisualStudio.Text;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Xunit;
using Xunit.Abstractions;
using static Microsoft.AspNetCore.Razor.Language.CommonMetadata;
namespace Microsoft.VisualStudio.Editor.Razor;
public class RazorSyntaxTreePartialParserTest : ToolingParserTestBase
public class RazorSyntaxTreePartialParserTest(ITestOutputHelper testOutput) : ToolingParserTestBase(testOutput)
{
private const string NewLine = "\r\n";
public RazorSyntaxTreePartialParserTest(ITestOutputHelper testOutput)
: base(testOutput)
{
}
protected override bool EnableSpanEditHandlers => true;
public static TheoryData TagHelperPartialParseRejectData

Просмотреть файл

@ -5,6 +5,7 @@
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Moq;
@ -13,13 +14,8 @@ using Xunit.Abstractions;
namespace Microsoft.VisualStudio.Editor.Razor;
public class RazorTextViewConnectionListenerTest : ProjectSnapshotManagerDispatcherTestBase
public class RazorTextViewConnectionListenerTest(ITestOutputHelper testOutput) : ProjectSnapshotManagerDispatcherTestBase(testOutput)
{
public RazorTextViewConnectionListenerTest(ITestOutputHelper testOutput)
: base(testOutput)
{
}
[UIFact]
public void SubjectBuffersConnected_CallsRazorDocumentManager_OnTextViewOpened()
{

Просмотреть файл

@ -5,19 +5,14 @@
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.VisualStudio.Test;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.VisualStudio.Text;
public class TextContentChangedEventArgsExtensionsTest : ToolingTestBase
public class TextContentChangedEventArgsExtensionsTest(ITestOutputHelper testOutput) : ToolingTestBase(testOutput)
{
public TextContentChangedEventArgsExtensionsTest(ITestOutputHelper testOutput)
: base(testOutput)
{
}
[Fact]
public void TextChangeOccurred_NoChanges_ReturnsFalse()
{

Просмотреть файл

@ -5,14 +5,10 @@
<IsShipping>false</IsShipping>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Moq" Version="$(MoqPackageVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.VisualStudio.LanguageServer.ContainedLanguage\Microsoft.VisualStudio.LanguageServer.ContainedLanguage.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.LanguageServer.Test.Common\Microsoft.AspNetCore.Razor.LanguageServer.Test.Common.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.Editor.Razor.Test.Common\Microsoft.VisualStudio.Editor.Razor.Test.Common.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Test.Common.Tooling\Microsoft.AspNetCore.Razor.Test.Common.Tooling.csproj" />
</ItemGroup>
</Project>

Просмотреть файл

@ -5,7 +5,7 @@
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.Test;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.VisualStudio.Text;
namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage;

Просмотреть файл

@ -5,7 +5,7 @@
using System;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.VisualStudio.Test;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.VisualStudio.Text;
using Moq;
using Xunit;
@ -13,15 +13,9 @@ using Xunit.Abstractions;
namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
public class DefaultFileUriProviderTest : ToolingTestBase
public class DefaultFileUriProviderTest(ITestOutputHelper testOutput) : ToolingTestBase(testOutput)
{
private readonly ITextBuffer _textBuffer;
public DefaultFileUriProviderTest(ITestOutputHelper testOutput)
: base(testOutput)
{
_textBuffer = new TestTextBuffer(StringTextSnapshot.Empty);
}
private readonly ITextBuffer _textBuffer = new TestTextBuffer(StringTextSnapshot.Empty);
[Fact]
public void AddOrUpdate_Adds()

Просмотреть файл

@ -7,7 +7,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.VisualStudio.Test;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Utilities;
using Moq;

Просмотреть файл

@ -7,8 +7,8 @@ using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage.Extensions;
using Microsoft.VisualStudio.Test;
using Microsoft.VisualStudio.Text;
using Moq;
using Xunit;

Просмотреть файл

@ -6,7 +6,7 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.VisualStudio.Test;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Utilities;
using Moq;

Просмотреть файл

@ -19,7 +19,6 @@
<ItemGroup>
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.LanguageServer.Test.Common\Microsoft.AspNetCore.Razor.LanguageServer.Test.Common.csproj" />
<ProjectReference Include="..\..\src\Microsoft.VisualStudio.LanguageServer.ContainedLanguage\Microsoft.VisualStudio.LanguageServer.ContainedLanguage.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.Editor.Razor.Test\Microsoft.VisualStudio.Editor.Razor.Test.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.LanguageServer.ContainedLanguage.Test.Common\Microsoft.VisualStudio.LanguageServer.ContainedLanguage.Test.Common.csproj" />
</ItemGroup>

Просмотреть файл

@ -5,9 +5,9 @@
using System;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage.Extensions;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage.Test.Common;
using Microsoft.VisualStudio.Test;
using Microsoft.VisualStudio.Text;
using Xunit;
using Xunit.Abstractions;

Просмотреть файл

@ -7,11 +7,11 @@ using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.VisualStudio.Editor.Razor.Debugging;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Microsoft.VisualStudio.LanguageServerClient.Razor.Test;
using Microsoft.VisualStudio.Test;
using Microsoft.VisualStudio.Text;
using Moq;
using Xunit;

Просмотреть файл

@ -8,13 +8,13 @@ using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
using Microsoft.VisualStudio.Editor.Razor;
using Microsoft.VisualStudio.Editor.Razor.Debugging;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Microsoft.VisualStudio.LanguageServerClient.Razor.Test;
using Microsoft.VisualStudio.Test;
using Microsoft.VisualStudio.Text;
using Moq;
using Xunit;

Просмотреть файл

@ -9,6 +9,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.LanguageServer.Common;
using Microsoft.AspNetCore.Razor.LanguageServer.Protocol;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Microsoft.VisualStudio.LanguageServerClient.Razor.Test;

Просмотреть файл

@ -13,10 +13,8 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.VisualStudio.Editor.Razor.Test.Common\Microsoft.VisualStudio.Editor.Razor.Test.Common.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.LanguageServer.Test.Common\Microsoft.AspNetCore.Razor.LanguageServer.Test.Common.csproj" />
<ProjectReference Include="..\..\src\Microsoft.VisualStudio.LanguageServerClient.Razor\Microsoft.VisualStudio.LanguageServerClient.Razor.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.Editor.Razor.Test\Microsoft.VisualStudio.Editor.Razor.Test.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.LanguageServer.ContainedLanguage.Test.Common\Microsoft.VisualStudio.LanguageServer.ContainedLanguage.Test.Common.csproj" />
</ItemGroup>

Просмотреть файл

@ -14,6 +14,7 @@ using Microsoft.AspNetCore.Razor.LanguageServer.Semantic;
using Microsoft.AspNetCore.Razor.LanguageServer.Semantic.Models;
using Microsoft.AspNetCore.Razor.Telemetry;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.AspNetCore.Razor.Test.Common.ProjectSystem;
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
using Microsoft.CodeAnalysis.Razor.Workspaces;
@ -25,7 +26,6 @@ using Microsoft.VisualStudio.Editor.Razor.Snippets;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Microsoft.VisualStudio.LanguageServerClient.Razor.Test;
using Microsoft.VisualStudio.Test;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Threading;
using Moq;

Просмотреть файл

@ -9,12 +9,12 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.LanguageServer.Protocol;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Microsoft.VisualStudio.LanguageServerClient.Razor.DocumentMapping;
using Microsoft.VisualStudio.LanguageServerClient.Razor.Extensions;
using Microsoft.VisualStudio.Text;
using Moq;
using Xunit;
using Xunit.Abstractions;

Просмотреть файл

@ -2,6 +2,7 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Operations;
using Microsoft.VisualStudio.Utilities;

Просмотреть файл

@ -7,10 +7,10 @@ using System;
using System.Collections.Generic;
using System.Threading;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.Editor.Razor;
using Microsoft.VisualStudio.Editor.Razor.Debugging;
using Microsoft.VisualStudio.Test;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.TextManager.Interop;
using Microsoft.VisualStudio.Utilities;
@ -22,15 +22,9 @@ using Range = Microsoft.VisualStudio.LanguageServer.Protocol.Range;
namespace Microsoft.VisualStudio.LanguageServices.Razor;
public class RazorLanguageService_IVsLanguageDebugInfoTest : ToolingTestBase
public class RazorLanguageService_IVsLanguageDebugInfoTest(ITestOutputHelper testOutput) : ToolingTestBase(testOutput)
{
private readonly TextSpan[] _textSpans;
public RazorLanguageService_IVsLanguageDebugInfoTest(ITestOutputHelper testOutput)
: base(testOutput)
{
_textSpans = new[] { new TextSpan() };
}
private readonly TextSpan[] _textSpans = [new TextSpan()];
[Fact]
public void ValidateBreakpointLocation_CanNotGetBackingTextBuffer_ReturnsNotImpl()

Просмотреть файл

@ -10,6 +10,7 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.AspNetCore.Razor.Test.Common.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Text;
@ -31,11 +32,11 @@ public class BackgroundDocumentGeneratorTest : ProjectSnapshotManagerDispatcherW
public BackgroundDocumentGeneratorTest(ITestOutputHelper testOutput)
: base(testOutput)
{
_documents = new HostDocument[]
{
_documents =
[
TestProjectData.SomeProjectFile1,
TestProjectData.AnotherProjectFile1,
};
];
_hostProject1 = new HostProject(TestProjectData.SomeProject.FilePath, TestProjectData.SomeProject.IntermediateOutputPath, FallbackRazorConfiguration.MVC_1_0, TestProjectData.SomeProject.RootNamespace);
_hostProject2 = new HostProject(TestProjectData.AnotherProject.FilePath, TestProjectData.AnotherProject.IntermediateOutputPath, FallbackRazorConfiguration.MVC_1_0, TestProjectData.AnotherProject.RootNamespace);

Просмотреть файл

@ -6,6 +6,7 @@
using System;
using System.Threading;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Threading;
@ -16,13 +17,8 @@ using Task = System.Threading.Tasks.Task;
namespace Microsoft.VisualStudio.Editor.Razor.Documents;
public class VisualStudioFileChangeTrackerTest : ProjectSnapshotManagerDispatcherTestBase
public class VisualStudioFileChangeTrackerTest(ITestOutputHelper testOutput) : ProjectSnapshotManagerDispatcherTestBase(testOutput)
{
public VisualStudioFileChangeTrackerTest(ITestOutputHelper testOutput)
: base(testOutput)
{
}
[UIFact]
public async Task StartListening_AdvisesForFileChange()
{

Просмотреть файл

@ -28,9 +28,9 @@
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.VisualStudio.LanguageServices.Razor\Microsoft.VisualStudio.LanguageServices.Razor.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.Editor.Razor.Test.Common\Microsoft.VisualStudio.Editor.Razor.Test.Common.csproj" />
<ProjectReference Include="..\..\..\Compiler\Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X\src\Microsoft.CodeAnalysis.Razor.Compiler.Mvc.Version1_X.csproj" />
<ProjectReference Include="..\..\..\Compiler\Microsoft.AspNetCore.Mvc.Razor.Extensions\src\Microsoft.CodeAnalysis.Razor.Compiler.Mvc.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Test.Common.Tooling\Microsoft.AspNetCore.Razor.Test.Common.Tooling.csproj" />
</ItemGroup>
</Project>

Просмотреть файл

@ -12,6 +12,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Text;
using Moq;

Просмотреть файл

@ -7,10 +7,10 @@ using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.AspNetCore.Razor.Test.Common.ProjectSystem;
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Moq;

Просмотреть файл

@ -11,6 +11,7 @@ using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.VisualStudio.ProjectSystem;
using Microsoft.VisualStudio.ProjectSystem.Properties;
using Moq;

Просмотреть файл

@ -9,6 +9,7 @@ using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.VisualStudio.ProjectSystem;
using Microsoft.VisualStudio.ProjectSystem.Properties;
using Moq;

Просмотреть файл

@ -11,13 +11,8 @@ using Xunit.Abstractions;
namespace Microsoft.VisualStudio.LiveShare.Razor.Guest;
public class DefaultProxyAccessorTest : ToolingTestBase
public class DefaultProxyAccessorTest(ITestOutputHelper testOutput) : ToolingTestBase(testOutput)
{
public DefaultProxyAccessorTest(ITestOutputHelper testOutput)
: base(testOutput)
{
}
[Fact]
public void GetProjectHierarchyProxy_Caches()
{

Просмотреть файл

@ -10,9 +10,9 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.AspNetCore.Razor.Test.Common.ProjectSystem;
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.VisualStudio.LiveShare.Razor.Test;
using Moq;

Просмотреть файл

@ -8,6 +8,7 @@ using System.Collections.Immutable;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;

Просмотреть файл

@ -12,7 +12,7 @@
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.VisualStudio.LiveShare.Razor\Microsoft.VisualStudio.LiveShare.Razor.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.Editor.Razor.Test.Common\Microsoft.VisualStudio.Editor.Razor.Test.Common.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Test.Common.Tooling\Microsoft.AspNetCore.Razor.Test.Common.Tooling.csproj" />
</ItemGroup>
</Project>

Просмотреть файл

@ -29,7 +29,6 @@
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>False</CopyLocalSatelliteAssemblies>
</ProjectReference>
<ProjectReference Include="..\Microsoft.VisualStudio.Editor.Razor.Test.Common\Microsoft.VisualStudio.Editor.Razor.Test.Common.csproj" />
</ItemGroup>
<ItemGroup>