From 83f585e5836e8315b23120141d7fb85aa9c441a3 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Tue, 24 Jun 2014 12:28:48 -0700 Subject: [PATCH] Addressed stylecop and CR issues. #568 --- .../ModelChunk.cs | 7 +++++-- .../ModelChunkVisitor.cs | 8 ++++++-- .../ModelCodeGenerator.cs | 7 +++++-- .../MvcCSharpChunkVisitor.cs | 8 ++++++-- .../MvcCSharpCodeBuilder.cs | 16 ++++++++-------- .../MvcCSharpCodeVistor.cs | 3 ++- 6 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/ModelChunk.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/ModelChunk.cs index 0b034fd66a..da7465c4b5 100644 --- a/src/Microsoft.AspNet.Mvc.Razor.Host/ModelChunk.cs +++ b/src/Microsoft.AspNet.Mvc.Razor.Host/ModelChunk.cs @@ -1,4 +1,7 @@ -using Microsoft.AspNet.Razor.Generator.Compiler; +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNet.Razor.Generator.Compiler; namespace Microsoft.AspNet.Mvc.Razor { @@ -9,7 +12,7 @@ namespace Microsoft.AspNet.Mvc.Razor /// /// The base type of the view. /// The type of the view's Model. - public ModelChunk(string baseType, string modelType) + public ModelChunk(string baseType, string modelType) { BaseType = baseType; ModelType = modelType; diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/ModelChunkVisitor.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/ModelChunkVisitor.cs index 8c38523769..78eb748e5c 100644 --- a/src/Microsoft.AspNet.Mvc.Razor.Host/ModelChunkVisitor.cs +++ b/src/Microsoft.AspNet.Mvc.Razor.Host/ModelChunkVisitor.cs @@ -1,4 +1,7 @@ -using Microsoft.AspNet.Razor.Generator; +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNet.Razor.Generator; using Microsoft.AspNet.Razor.Generator.Compiler.CSharp; namespace Microsoft.AspNet.Mvc.Razor @@ -8,7 +11,8 @@ namespace Microsoft.AspNet.Mvc.Razor public ModelChunkVisitor([NotNull] CSharpCodeWriter writer, [NotNull] CodeGeneratorContext context) : base(writer, context) - { } + { + } protected override void Visit(ModelChunk chunk) { diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/ModelCodeGenerator.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/ModelCodeGenerator.cs index 632678dcba..1e2f2f2cdd 100644 --- a/src/Microsoft.AspNet.Mvc.Razor.Host/ModelCodeGenerator.cs +++ b/src/Microsoft.AspNet.Mvc.Razor.Host/ModelCodeGenerator.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; using Microsoft.AspNet.Mvc.Razor; using Microsoft.AspNet.Razor.Parser.SyntaxTree; @@ -23,7 +26,7 @@ namespace Microsoft.AspNet.Razor.Generator public override string ToString() { - return "Full Model Type: " + BaseType + "<" + ModelType + ">"; + return BaseType + "<" + ModelType + ">"; } public override bool Equals(object obj) diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpChunkVisitor.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpChunkVisitor.cs index 887466eed5..a61a9c999f 100644 --- a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpChunkVisitor.cs +++ b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpChunkVisitor.cs @@ -1,4 +1,7 @@ -using Microsoft.AspNet.Razor.Generator; +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNet.Razor.Generator; using Microsoft.AspNet.Razor.Generator.Compiler; using Microsoft.AspNet.Razor.Generator.Compiler.CSharp; @@ -9,7 +12,8 @@ namespace Microsoft.AspNet.Mvc.Razor public MvcCSharpChunkVisitor([NotNull] CSharpCodeWriter writer, [NotNull] CodeGeneratorContext context) : base(writer, context) - { } + { + } public override void Accept(Chunk chunk) { diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpCodeBuilder.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpCodeBuilder.cs index fe4e3082cb..9114f0383c 100644 --- a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpCodeBuilder.cs +++ b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpCodeBuilder.cs @@ -19,20 +19,20 @@ namespace Microsoft.AspNet.Mvc.Razor protected override CSharpCodeWritingScope BuildClassDeclaration(CSharpCodeWriter writer) { - var modelChunks = Context.CodeTreeBuilder.CodeTree.Chunks.OfType(); + // Grab the last model chunk so it gets intellisense. + // NOTE: If there's more than 1 model chunk there will be a Razor error BUT we want intellisense to + // show up on the current model chunk that the user is typing. + var modelChunk = Context.CodeTreeBuilder.CodeTree.Chunks.OfType() + .LastOrDefault(); // If there were any model chunks then we need to modify the class declaration signature. - if (modelChunks.Any()) + if (modelChunk != null) { - writer.Write(string.Format(CultureInfo.CurrentCulture, "public class {0} : ", Context.ClassName)); + writer.Write(string.Format(CultureInfo.InvariantCulture, "public class {0} : ", Context.ClassName)); - // Grab the last model chunk so it gets intellisense. - // NOTE: If there's more than 1 model chunk there will be a Razor error BUT we want intellisense to show up - // on the current model chunk that the user is typing. - var lastModelChunk = modelChunks.Last(); var modelVisitor = new ModelChunkVisitor(writer, Context); // This generates the base class signature - modelVisitor.Accept(lastModelChunk); + modelVisitor.Accept(modelChunk); writer.WriteLine(); diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpCodeVistor.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpCodeVistor.cs index 334873d574..8ec35bc986 100644 --- a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpCodeVistor.cs +++ b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpCodeVistor.cs @@ -11,7 +11,8 @@ namespace Microsoft.AspNet.Mvc.Razor public MvcCSharpCodeVisitor([NotNull] CSharpCodeWriter writer, [NotNull] CodeGeneratorContext context) : base(writer, context) - { } + { + } protected override void Visit(InjectChunk chunk) {