Fix #2041 - Add static constructor to DocumentWriter
The instance Create method was always supposed to be static.
This commit is contained in:
parent
d6784b5f16
commit
e05c2abd94
|
|
@ -2,12 +2,30 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
using Microsoft.AspNetCore.Razor.Language.Intermediate;
|
using Microsoft.AspNetCore.Razor.Language.Intermediate;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
||||||
{
|
{
|
||||||
public abstract class DocumentWriter
|
public abstract class DocumentWriter
|
||||||
{
|
{
|
||||||
|
public static DocumentWriter CreateDefault(CodeTarget codeTarget, RazorCodeGenerationOptions options)
|
||||||
|
{
|
||||||
|
if (codeTarget == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(codeTarget));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(options));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new DefaultDocumentWriter(codeTarget, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
[Obsolete("This method was intended to be static, use CreateDefault instead.")]
|
||||||
public DocumentWriter Create(CodeTarget codeTarget, RazorCodeGenerationOptions options)
|
public DocumentWriter Create(CodeTarget codeTarget, RazorCodeGenerationOptions options)
|
||||||
{
|
{
|
||||||
if (codeTarget == null)
|
if (codeTarget == null)
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
||||||
throw new InvalidOperationException(message);
|
throw new InvalidOperationException(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
var writer = new DefaultDocumentWriter(documentNode.Target, documentNode.Options);
|
var writer = DocumentWriter.CreateDefault(documentNode.Target, documentNode.Options);
|
||||||
var cSharpDocument = writer.WriteDocument(codeDocument, documentNode);
|
var cSharpDocument = writer.WriteDocument(codeDocument, documentNode);
|
||||||
codeDocument.SetCSharpDocument(cSharpDocument);
|
codeDocument.SetCSharpDocument(cSharpDocument);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue