Fix #2041 - Add static constructor to DocumentWriter

The instance Create method was always supposed to be static.

(cherry picked from commit e05c2abd94)
This commit is contained in:
Ryan Nowak 2018-02-28 13:21:04 -08:00
parent 62df770c39
commit 3e0360a891
2 changed files with 19 additions and 1 deletions

View File

@ -2,12 +2,30 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.ComponentModel;
using Microsoft.AspNetCore.Razor.Language.Intermediate;
namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
{
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)
{
if (codeTarget == null)

View File

@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Razor.Language
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);
codeDocument.SetCSharpDocument(cSharpDocument);
}