зеркало из https://github.com/dotnet/razor.git
Swap RazorCSharpDocument.Create methods for constructors
This commit is contained in:
Родитель
89204d4acf
Коммит
c755804389
|
@ -113,7 +113,7 @@ public class RazorCodeDocumentExtensionsTest
|
|||
// Arrange
|
||||
var codeDocument = TestRazorCodeDocument.CreateEmpty();
|
||||
|
||||
var expected = RazorCSharpDocument.Create(codeDocument, "", RazorCodeGenerationOptions.CreateDefault(), diagnostics: []);
|
||||
var expected = new RazorCSharpDocument(codeDocument, "", RazorCodeGenerationOptions.CreateDefault(), diagnostics: []);
|
||||
codeDocument.Items[typeof(RazorCSharpDocument)] = expected;
|
||||
|
||||
// Act
|
||||
|
@ -129,7 +129,7 @@ public class RazorCodeDocumentExtensionsTest
|
|||
// Arrange
|
||||
var codeDocument = TestRazorCodeDocument.CreateEmpty();
|
||||
|
||||
var expected = RazorCSharpDocument.Create(codeDocument, "", RazorCodeGenerationOptions.CreateDefault(), diagnostics: []);
|
||||
var expected = new RazorCSharpDocument(codeDocument, "", RazorCodeGenerationOptions.CreateDefault(), diagnostics: []);
|
||||
|
||||
// Act
|
||||
codeDocument.SetCSharpDocument(expected);
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Language;
|
||||
|
@ -22,11 +21,12 @@ public sealed class RazorCSharpDocument : IRazorGeneratedDocument
|
|||
string generatedCode,
|
||||
RazorCodeGenerationOptions options,
|
||||
RazorDiagnostic[] diagnostics,
|
||||
ImmutableArray<SourceMapping> sourceMappings,
|
||||
ImmutableArray<LinePragma> linePragmas)
|
||||
ImmutableArray<SourceMapping> sourceMappings = default,
|
||||
ImmutableArray<LinePragma> linePragmas = default)
|
||||
{
|
||||
ArgHelper.ThrowIfNull(codeDocument);
|
||||
ArgHelper.ThrowIfNull(generatedCode);
|
||||
ArgHelper.ThrowIfNull(options);
|
||||
|
||||
CodeDocument = codeDocument;
|
||||
GeneratedCode = generatedCode;
|
||||
|
@ -36,32 +36,4 @@ public sealed class RazorCSharpDocument : IRazorGeneratedDocument
|
|||
SourceMappings = sourceMappings.NullToEmpty();
|
||||
LinePragmas = linePragmas.NullToEmpty();
|
||||
}
|
||||
|
||||
public static RazorCSharpDocument Create(
|
||||
RazorCodeDocument codeDocument,
|
||||
string generatedCode,
|
||||
RazorCodeGenerationOptions options,
|
||||
IEnumerable<RazorDiagnostic> diagnostics)
|
||||
{
|
||||
ArgHelper.ThrowIfNull(generatedCode);
|
||||
ArgHelper.ThrowIfNull(options);
|
||||
ArgHelper.ThrowIfNull(diagnostics);
|
||||
|
||||
return new(codeDocument, generatedCode, options, diagnostics.ToArray(), sourceMappings: [], linePragmas: []);
|
||||
}
|
||||
|
||||
public static RazorCSharpDocument Create(
|
||||
RazorCodeDocument codeDocument,
|
||||
string generatedCode,
|
||||
RazorCodeGenerationOptions options,
|
||||
IEnumerable<RazorDiagnostic> diagnostics,
|
||||
ImmutableArray<SourceMapping> sourceMappings,
|
||||
ImmutableArray<LinePragma> linePragmas)
|
||||
{
|
||||
ArgHelper.ThrowIfNull(generatedCode);
|
||||
ArgHelper.ThrowIfNull(options);
|
||||
ArgHelper.ThrowIfNull(diagnostics);
|
||||
|
||||
return new(codeDocument, generatedCode, options, diagnostics.ToArray(), sourceMappings, linePragmas);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class RazorDiagnosticsBenchmark : RazorLanguageServerBenchmarkBase
|
|||
var stringSourceDocument = RazorSourceDocument.Create(GetFileContents(), UTF8Encoding.UTF8, RazorSourceDocumentProperties.Default);
|
||||
var mockRazorCodeDocument = new Mock<RazorCodeDocument>(MockBehavior.Strict);
|
||||
|
||||
var mockRazorCSharpDocument = RazorCSharpDocument.Create(
|
||||
var mockRazorCSharpDocument = new RazorCSharpDocument(
|
||||
mockRazorCodeDocument.Object,
|
||||
GeneratedCode,
|
||||
RazorCodeGenerationOptions.CreateDesignTimeDefault(),
|
||||
|
|
|
@ -14,12 +14,8 @@ internal class UnsupportedCSharpLoweringPhase : RazorEnginePhaseBase, IRazorCSha
|
|||
var documentNode = codeDocument.GetDocumentIntermediateNode();
|
||||
ThrowForMissingDocumentDependency(documentNode);
|
||||
|
||||
var cSharpDocument = RazorCSharpDocument.Create(
|
||||
codeDocument,
|
||||
UnsupportedDisclaimer,
|
||||
documentNode.Options,
|
||||
diagnostics: []);
|
||||
codeDocument.SetCSharpDocument(cSharpDocument);
|
||||
var csharpDocument = new RazorCSharpDocument(codeDocument, UnsupportedDisclaimer, documentNode.Options, diagnostics: []);
|
||||
codeDocument.SetCSharpDocument(csharpDocument);
|
||||
codeDocument.SetUnsupported();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -329,7 +329,7 @@ $$Path;
|
|||
var csharpDocument = codeDocument.GetCSharpDocument();
|
||||
var diagnosticDescriptor = new RazorDiagnosticDescriptor("RZ10012", "diagnostic", RazorDiagnosticSeverity.Error);
|
||||
var diagnostic = RazorDiagnostic.Create(diagnosticDescriptor, componentSourceSpan);
|
||||
var csharpDocumentWithDiagnostic = RazorCSharpDocument.Create(codeDocument, csharpDocument.GeneratedCode, csharpDocument.Options, [diagnostic]);
|
||||
var csharpDocumentWithDiagnostic = new RazorCSharpDocument(codeDocument, csharpDocument.GeneratedCode, csharpDocument.Options, [diagnostic]);
|
||||
codeDocument.SetCSharpDocument(csharpDocumentWithDiagnostic);
|
||||
|
||||
var documentSnapshot = Mock.Of<IDocumentSnapshot>(document =>
|
||||
|
|
|
@ -460,7 +460,7 @@ public class TypeAccessibilityCodeActionProviderTest(ITestOutputHelper testOutpu
|
|||
var csharpDocument = codeDocument.GetCSharpDocument();
|
||||
var diagnosticDescriptor = new RazorDiagnosticDescriptor("RZ10012", "diagnostic", RazorDiagnosticSeverity.Error);
|
||||
var diagnostic = RazorDiagnostic.Create(diagnosticDescriptor, componentSourceSpan);
|
||||
var csharpDocumentWithDiagnostic = RazorCSharpDocument.Create(codeDocument, csharpDocument.GeneratedCode, csharpDocument.Options, [diagnostic]);
|
||||
var csharpDocumentWithDiagnostic = new RazorCSharpDocument(codeDocument, csharpDocument.GeneratedCode, csharpDocument.Options, [diagnostic]);
|
||||
codeDocument.SetCSharpDocument(csharpDocumentWithDiagnostic);
|
||||
|
||||
var documentSnapshot = Mock.Of<IDocumentSnapshot>(document =>
|
||||
|
|
|
@ -460,7 +460,7 @@ public class ComponentAccessibilityCodeActionProviderTest(ITestOutputHelper test
|
|||
var csharpDocument = codeDocument.GetCSharpDocument();
|
||||
var diagnosticDescriptor = new RazorDiagnosticDescriptor("RZ10012", "diagnostic", RazorDiagnosticSeverity.Error);
|
||||
var diagnostic = RazorDiagnostic.Create(diagnosticDescriptor, componentSourceSpan);
|
||||
var csharpDocumentWithDiagnostic = RazorCSharpDocument.Create(codeDocument, csharpDocument.GeneratedCode, csharpDocument.Options, [diagnostic]);
|
||||
var csharpDocumentWithDiagnostic = new RazorCSharpDocument(codeDocument, csharpDocument.GeneratedCode, csharpDocument.Options, [diagnostic]);
|
||||
codeDocument.SetCSharpDocument(csharpDocumentWithDiagnostic);
|
||||
|
||||
var documentSnapshot = Mock.Of<IDocumentSnapshot>(document =>
|
||||
|
|
|
@ -528,7 +528,7 @@ public class RazorDiagnosticsPublisherTest(ITestOutputHelper testOutput) : Langu
|
|||
private static RazorCodeDocument CreateCodeDocument(IEnumerable<RazorDiagnostic> diagnostics)
|
||||
{
|
||||
var codeDocument = TestRazorCodeDocument.Create("hello");
|
||||
var razorCSharpDocument = RazorCSharpDocument.Create(codeDocument, "hello", RazorCodeGenerationOptions.CreateDefault(), diagnostics.ToImmutableArray());
|
||||
var razorCSharpDocument = new RazorCSharpDocument(codeDocument, "hello", RazorCodeGenerationOptions.CreateDefault(), diagnostics.ToImmutableArray());
|
||||
codeDocument.SetCSharpDocument(razorCSharpDocument);
|
||||
|
||||
return codeDocument;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -24,7 +22,7 @@ public abstract class FormattingLanguageServerTestBase(ITestOutputHelper testOut
|
|||
var sourceDocument = TestRazorSourceDocument.Create(content);
|
||||
var codeDocument = RazorCodeDocument.Create(sourceDocument);
|
||||
var syntaxTree = RazorSyntaxTree.Parse(sourceDocument, RazorParserOptions.CreateDefault());
|
||||
var razorCSharpDocument = RazorCSharpDocument.Create(
|
||||
var razorCSharpDocument = new RazorCSharpDocument(
|
||||
codeDocument, content, RazorCodeGenerationOptions.CreateDefault(), diagnostics: [], sourceMappings, linePragmas: []);
|
||||
codeDocument.SetSyntaxTree(syntaxTree);
|
||||
codeDocument.SetCSharpDocument(razorCSharpDocument);
|
||||
|
|
|
@ -145,7 +145,7 @@ public class RazorLanguageQueryEndpointTest : LanguageServerTestBase
|
|||
private static RazorCodeDocument CreateCodeDocumentWithCSharpProjection(string razorSource, string projectedCSharpSource, ImmutableArray<SourceMapping> sourceMappings)
|
||||
{
|
||||
var codeDocument = CreateCodeDocument(razorSource, tagHelpers: []);
|
||||
var csharpDocument = RazorCSharpDocument.Create(
|
||||
var csharpDocument = new RazorCSharpDocument(
|
||||
codeDocument,
|
||||
projectedCSharpSource,
|
||||
RazorCodeGenerationOptions.CreateDefault(),
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
@ -232,7 +231,7 @@ public class RazorMapToDocumentRangesEndpointTest : LanguageServerTestBase
|
|||
private static RazorCodeDocument CreateCodeDocumentWithCSharpProjection(string razorSource, string projectedCSharpSource, ImmutableArray<SourceMapping> sourceMappings)
|
||||
{
|
||||
var codeDocument = CreateCodeDocument(razorSource, tagHelpers: []);
|
||||
var csharpDocument = RazorCSharpDocument.Create(
|
||||
var csharpDocument = new RazorCSharpDocument(
|
||||
codeDocument,
|
||||
projectedCSharpSource,
|
||||
RazorCodeGenerationOptions.CreateDefault(),
|
||||
|
|
|
@ -1032,12 +1032,12 @@ public class RazorDocumentMappingServiceTest(ITestOutputHelper testOutput) : Too
|
|||
private static RazorCodeDocument CreateCodeDocumentWithCSharpProjection(string razorSource, string projectedCSharpSource, ImmutableArray<SourceMapping> sourceMappings)
|
||||
{
|
||||
var codeDocument = CreateCodeDocument(razorSource, tagHelpers: []);
|
||||
var csharpDocument = RazorCSharpDocument.Create(
|
||||
var csharpDocument = new RazorCSharpDocument(
|
||||
codeDocument,
|
||||
projectedCSharpSource,
|
||||
RazorCodeGenerationOptions.CreateDefault(),
|
||||
diagnostics: [],
|
||||
sourceMappings.ToImmutableArray(),
|
||||
sourceMappings,
|
||||
linePragmas: []);
|
||||
codeDocument.SetCSharpDocument(csharpDocument);
|
||||
return codeDocument;
|
||||
|
|
Загрузка…
Ссылка в новой задаче