Code Cleanup
Use var Conditional can be simplified Redundant array creation expression Parameter name differs in base declaration Empty statement is redundant
This commit is contained in:
parent
2ab54e73c5
commit
b03d3aa56f
|
|
@ -45,9 +45,9 @@ namespace Microsoft.AspNetCore.Razor
|
|||
return new RazorChunkGenerator(className, rootNamespaceName, sourceFileName, host);
|
||||
}
|
||||
|
||||
public override CodeGenerator CreateCodeGenerator(CodeGeneratorContext context)
|
||||
public override CodeGenerator CreateCodeGenerator(CodeGeneratorContext chunkGeneratorContext)
|
||||
{
|
||||
return new CSharpCodeGenerator(context);
|
||||
return new CSharpCodeGenerator(chunkGeneratorContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Razor.Chunks.Generators
|
|||
ClassName = className;
|
||||
RootNamespaceName = rootNamespaceName;
|
||||
SourceFileName = sourceFileName;
|
||||
GenerateLinePragmas = string.IsNullOrEmpty(SourceFileName) ? false : true;
|
||||
GenerateLinePragmas = !string.IsNullOrEmpty(SourceFileName);
|
||||
Host = host;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ namespace Microsoft.AspNetCore.Razor.CodeGenerators
|
|||
using (writer.BuildConstructor(Context.ClassName))
|
||||
{
|
||||
// Any constructor based logic that we need to add?
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private void AddImports(ChunkTree chunkTree, CSharpCodeWriter writer, IEnumerable<string> defaultImports)
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@ namespace Microsoft.AspNetCore.Razor.CodeGenerators
|
|||
{
|
||||
private const string InstanceMethodFormat = "{0}.{1}";
|
||||
|
||||
private static readonly char[] CStyleStringLiteralEscapeChars = new char[]
|
||||
{
|
||||
private static readonly char[] CStyleStringLiteralEscapeChars = {
|
||||
'\r',
|
||||
'\t',
|
||||
'\"',
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace Microsoft.AspNetCore.Razor.CodeGenerators
|
|||
{
|
||||
public class CodeWriter : IDisposable
|
||||
{
|
||||
private static readonly char[] NewLineCharacters = new char[] { '\r', '\n' };
|
||||
private static readonly char[] NewLineCharacters = { '\r', '\n' };
|
||||
|
||||
private string _cache = string.Empty;
|
||||
private bool _dirty;
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Parser
|
|||
{
|
||||
public partial class HtmlMarkupParser
|
||||
{
|
||||
private static readonly char[] ValidAfterTypeAttributeNameCharacters =
|
||||
new[] { ' ', '\t', '\r', '\n', '\f', '=' };
|
||||
private static readonly char[] ValidAfterTypeAttributeNameCharacters = { ' ', '\t', '\r', '\n', '\f', '=' };
|
||||
|
||||
public override void ParseDocument()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ namespace Microsoft.AspNetCore.Razor.Text
|
|||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
LocationTagged<TValue> other = obj as LocationTagged<TValue>;
|
||||
var other = obj as LocationTagged<TValue>;
|
||||
if (ReferenceEquals(other, null))
|
||||
{
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace Microsoft.AspNetCore.Razor.Tokenizer.Symbols
|
|||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
SymbolBase<TType> other = obj as SymbolBase<TType>;
|
||||
var other = obj as SymbolBase<TType>;
|
||||
return other != null &&
|
||||
Start.Equals(other.Start) &&
|
||||
string.Equals(Content, other.Content, StringComparison.Ordinal) &&
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers
|
|||
{
|
||||
public class TagHelperTypeResolverTest
|
||||
{
|
||||
protected static readonly Type[] ValidTestableTagHelpers = new[]
|
||||
protected static readonly Type[] ValidTestableTagHelpers =
|
||||
{
|
||||
typeof(Valid_PlainTagHelper),
|
||||
typeof(Valid_InheritedTagHelper)
|
||||
};
|
||||
|
||||
protected static readonly Type[] InvalidTestableTagHelpers = new[]
|
||||
protected static readonly Type[] InvalidTestableTagHelpers =
|
||||
{
|
||||
typeof(Invalid_AbstractTagHelper),
|
||||
typeof(Invalid_GenericTagHelper<>),
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ namespace Microsoft.AspNetCore.Razor.Test.Generator
|
|||
private class CustomTagHelperAttributeCodeRenderer : TagHelperAttributeValueCodeRenderer
|
||||
{
|
||||
public override void RenderAttributeValue(
|
||||
TagHelperAttributeDescriptor attributeInfo,
|
||||
TagHelperAttributeDescriptor attributeDescriptor,
|
||||
CSharpCodeWriter writer,
|
||||
CodeGeneratorContext context,
|
||||
Action<CSharpCodeWriter> renderAttributeValue,
|
||||
|
|
@ -109,7 +109,7 @@ namespace Microsoft.AspNetCore.Razor.Test.Generator
|
|||
{
|
||||
writer.Write("**From custom attribute code renderer**: ");
|
||||
|
||||
base.RenderAttributeValue(attributeInfo, writer, context, renderAttributeValue, complexValue);
|
||||
base.RenderAttributeValue(attributeDescriptor, writer, context, renderAttributeValue, complexValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,9 +82,9 @@ namespace Microsoft.AspNetCore.Razor.Test.Generator
|
|||
return Host.DecorateCodeGenerator(new TestCSharpCodeGenerator(context), context);
|
||||
}
|
||||
|
||||
protected internal override RazorParser CreateParser(string fileName)
|
||||
protected internal override RazorParser CreateParser(string sourceFileName)
|
||||
{
|
||||
var parser = base.CreateParser(fileName);
|
||||
var parser = base.CreateParser(sourceFileName);
|
||||
|
||||
return new RazorParser(parser.CodeParser,
|
||||
parser.MarkupParser,
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ namespace Microsoft.AspNetCore.Razor.Test.Parser
|
|||
private static void RunSyncContextTest<T>(T expected, Func<Action<T>, CallbackVisitor> ctor, Action<CallbackVisitor, T> call)
|
||||
{
|
||||
// Arrange
|
||||
Mock<SynchronizationContext> mockContext = new Mock<SynchronizationContext>();
|
||||
var mockContext = new Mock<SynchronizationContext>();
|
||||
mockContext.Setup(c => c.Post(It.IsAny<SendOrPostCallback>(), It.IsAny<object>()))
|
||||
.Callback<SendOrPostCallback, object>((callback, state) => { callback(expected); });
|
||||
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ namespace Microsoft.AspNetCore.Razor.Test.Parser
|
|||
public void EndBlockAddsCurrentBlockToParentBlock()
|
||||
{
|
||||
// Arrange
|
||||
Mock<ParserVisitor> mockListener = new Mock<ParserVisitor>();
|
||||
var mockListener = new Mock<ParserVisitor>();
|
||||
var context = SetupTestContext("phoo");
|
||||
|
||||
// Act
|
||||
|
|
@ -147,7 +147,7 @@ namespace Microsoft.AspNetCore.Razor.Test.Parser
|
|||
{
|
||||
// Arrange
|
||||
var factory = SpanFactory.CreateCsHtml();
|
||||
Mock<ParserVisitor> mockListener = new Mock<ParserVisitor>();
|
||||
var mockListener = new Mock<ParserVisitor>();
|
||||
var context = SetupTestContext("phoo");
|
||||
|
||||
var builder = new SpanBuilder()
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace Microsoft.AspNetCore.Razor.Test.Parser
|
|||
public void VisitSendsDocumentToVisitor()
|
||||
{
|
||||
// Arrange
|
||||
Mock<ParserVisitor> targetMock = new Mock<ParserVisitor>();
|
||||
var targetMock = new Mock<ParserVisitor>();
|
||||
var root = new BlockBuilder() { Type = BlockType.Comment }.Build();
|
||||
var errorSink = new ErrorSink();
|
||||
var results = new ParserResults(root,
|
||||
|
|
@ -35,10 +35,10 @@ namespace Microsoft.AspNetCore.Razor.Test.Parser
|
|||
public void VisitSendsErrorsToVisitor()
|
||||
{
|
||||
// Arrange
|
||||
Mock<ParserVisitor> targetMock = new Mock<ParserVisitor>();
|
||||
var targetMock = new Mock<ParserVisitor>();
|
||||
var root = new BlockBuilder() { Type = BlockType.Comment }.Build();
|
||||
var errorSink = new ErrorSink();
|
||||
List<RazorError> errors = new List<RazorError>
|
||||
var errors = new List<RazorError>
|
||||
{
|
||||
new RazorError("Foo", new SourceLocation(1, 0, 1), length: 3),
|
||||
new RazorError("Bar", new SourceLocation(2, 0, 2), length: 3),
|
||||
|
|
@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Razor.Test.Parser
|
|||
public void VisitCallsOnCompleteWhenAllNodesHaveBeenVisited()
|
||||
{
|
||||
// Arrange
|
||||
Mock<ParserVisitor> targetMock = new Mock<ParserVisitor>();
|
||||
var targetMock = new Mock<ParserVisitor>();
|
||||
var root = new BlockBuilder() { Type = BlockType.Comment }.Build();
|
||||
var errorSink = new ErrorSink();
|
||||
errorSink.OnError(new RazorError("Foo", new SourceLocation(1, 0, 1), length: 3));
|
||||
|
|
|
|||
Loading…
Reference in New Issue