Comment ifdefs and fix K10 functionality

This commit is contained in:
N. Taylor Mullen 2014-01-30 15:50:01 -08:00
parent 9f80b7d1c8
commit 7f0878c1b8
38 changed files with 183 additions and 32 deletions

View File

@ -22,6 +22,8 @@ namespace Microsoft.AspNet.Razor
get { return CSharpLanguageName; } get { return CSharpLanguageName; }
} }
#if NET45 #if NET45
// No CodeDOM in CoreCLR
/// <summary> /// <summary>
/// Returns the type of the CodeDOM provider for this language /// Returns the type of the CodeDOM provider for this language
/// </summary> /// </summary>

View File

@ -310,6 +310,11 @@ namespace Microsoft.AspNet.Razor.Editor
{ {
RazorEditorTrace.TraceLine(RazorResources.Trace_BackgroundThreadStart, fileNameOnly); RazorEditorTrace.TraceLine(RazorResources.Trace_BackgroundThreadStart, fileNameOnly);
EnsureOnThread(); EnsureOnThread();
#if K10
var spinWait = new SpinWait();
#endif
while (!_shutdownToken.IsCancellationRequested) while (!_shutdownToken.IsCancellationRequested)
{ {
// Grab the parcel of work to do // Grab the parcel of work to do
@ -425,7 +430,12 @@ namespace Microsoft.AspNet.Razor.Editor
{ {
RazorEditorTrace.TraceLine(RazorResources.Trace_NoChangesArrived, fileNameOnly, parcel.Changes.Count); RazorEditorTrace.TraceLine(RazorResources.Trace_NoChangesArrived, fileNameOnly, parcel.Changes.Count);
#if NET45 #if NET45
// No Yield in CoreCLR
Thread.Yield(); Thread.Yield();
#else
// This does the equivalent of thread.yield under the covers.
spinWait.SpinOnce();
#endif #endif
} }
} }

View File

@ -25,6 +25,8 @@ namespace Microsoft.AspNet.Razor.Editor
if (Boolean.TryParse(Environment.GetEnvironmentVariable("RAZOR_EDITOR_TRACE"), out enabled)) if (Boolean.TryParse(Environment.GetEnvironmentVariable("RAZOR_EDITOR_TRACE"), out enabled))
{ {
#if NET45 #if NET45
// No Trace in CoreCLR
Trace.WriteLine(String.Format( Trace.WriteLine(String.Format(
CultureInfo.CurrentCulture, CultureInfo.CurrentCulture,
RazorResources.Trace_Startup, RazorResources.Trace_Startup,
@ -46,6 +48,8 @@ namespace Microsoft.AspNet.Razor.Editor
if (IsEnabled()) if (IsEnabled())
{ {
#if NET45 #if NET45
// No Trace in CoreCLR
Trace.WriteLine(String.Format( Trace.WriteLine(String.Format(
CultureInfo.CurrentCulture, CultureInfo.CurrentCulture,
RazorResources.Trace_Format, RazorResources.Trace_Format,

View File

@ -36,6 +36,9 @@ namespace Microsoft.AspNet.Razor.Generator
public override void GenerateCode(Span target, CodeGeneratorContext context) public override void GenerateCode(Span target, CodeGeneratorContext context)
{ {
#if NET45 #if NET45
// No CodeDOM in CoreCLR.
// #if'd the entire section because once we transition over to the CodeTree we will not need all this code.
// Try to find the namespace in the existing imports // Try to find the namespace in the existing imports
string ns = Namespace; string ns = Namespace;
if (!String.IsNullOrEmpty(ns) && Char.IsWhiteSpace(ns[0])) if (!String.IsNullOrEmpty(ns) && Char.IsWhiteSpace(ns[0]))

View File

@ -34,6 +34,9 @@ namespace Microsoft.AspNet.Razor.Generator
public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context) public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context)
{ {
#if NET45 #if NET45
// No CodeDOM in CoreCLR.
// #if'd the entire section because once we transition over to the CodeTree we will not need all this code.
if (context.Host.DesignTimeMode) if (context.Host.DesignTimeMode)
{ {
return; // Don't generate anything! return; // Don't generate anything!
@ -72,6 +75,9 @@ namespace Microsoft.AspNet.Razor.Generator
public override void GenerateEndBlockCode(Block target, CodeGeneratorContext context) public override void GenerateEndBlockCode(Block target, CodeGeneratorContext context)
{ {
#if NET45 #if NET45
// No CodeDOM in CoreCLR (AddStatement and FlushBufferedStatement etc. utilize it).
// #if'd the entire section because once we transition over to the CodeTree we will not need all this code.
if (context.Host.DesignTimeMode) if (context.Host.DesignTimeMode)
{ {
return; // Don't generate anything! return; // Don't generate anything!

View File

@ -25,6 +25,9 @@ namespace Microsoft.AspNet.Razor.Generator
{ {
base.Initialize(context); base.Initialize(context);
#if NET45 #if NET45
// No CodeDOM in CoreCLR.
// #if'd the entire section because once we transition over to the CodeTree we will not need all this code.
context.GeneratedClass.Members.Insert(0, new CodeSnippetTypeMember(HiddenLinePragma)); context.GeneratedClass.Members.Insert(0, new CodeSnippetTypeMember(HiddenLinePragma));
#endif #endif
} }

View File

@ -32,6 +32,9 @@ namespace Microsoft.AspNet.Razor.Generator
#region deletable #region deletable
#if NET45 #if NET45
// This section is #if'd because it contains SOME incompatible pieces but also will not be needed once we transition over
// to using the CodeTree
private int _nextDesignTimePragmaId = 1; private int _nextDesignTimePragmaId = 1;
private bool _expressionHelperVariableWriten; private bool _expressionHelperVariableWriten;
private CodeMemberMethod _designTimeHelperMethod; private CodeMemberMethod _designTimeHelperMethod;
@ -318,6 +321,9 @@ namespace Microsoft.AspNet.Razor.Generator
Host = host, Host = host,
SourceFile = shouldGenerateLinePragmas ? sourceFile : null, SourceFile = shouldGenerateLinePragmas ? sourceFile : null,
#if NET45 #if NET45
// This section is #if'd because it contains SOME incompatible pieces but also will not be needed once we transition over
// to using the CodeTree
CodeWriterFactory = writerFactory, CodeWriterFactory = writerFactory,
CompileUnit = new CodeCompileUnit(), CompileUnit = new CodeCompileUnit(),
Namespace = new CodeNamespace(rootNamespace), Namespace = new CodeNamespace(rootNamespace),
@ -334,6 +340,8 @@ namespace Microsoft.AspNet.Razor.Generator
#endif #endif
}; };
#if NET45 #if NET45
// No CodeDOM in CoreCLR.
context.CompileUnit.Namespaces.Add(context.Namespace); context.CompileUnit.Namespaces.Add(context.Namespace);
context.Namespace.Types.Add(context.GeneratedClass); context.Namespace.Types.Add(context.GeneratedClass);
context.GeneratedClass.Members.Add(context.TargetMethod); context.GeneratedClass.Members.Add(context.TargetMethod);

View File

@ -10,6 +10,8 @@ using Microsoft.AspNet.Razor.Parser.SyntaxTree;
namespace Microsoft.AspNet.Razor.Generator namespace Microsoft.AspNet.Razor.Generator
{ {
#if NET45 #if NET45
// This section is #if'd because it is no longer needed for the CodeTree transition.
internal static class CodeGeneratorPaddingHelper internal static class CodeGeneratorPaddingHelper
{ {
private static readonly char[] _newLineChars = { '\r', '\n' }; private static readonly char[] _newLineChars = { '\r', '\n' };

View File

@ -54,6 +54,8 @@ namespace Microsoft.AspNet.Razor.Generator
public abstract void WriteStringLiteral(string literal); public abstract void WriteStringLiteral(string literal);
public abstract int WriteVariableDeclaration(string type, string name, string value); public abstract int WriteVariableDeclaration(string type, string name, string value);
#if NET45 #if NET45
// No CodeDOM in CoreCLR
public virtual void WriteLinePragma() public virtual void WriteLinePragma()
{ {
WriteLinePragma(null); WriteLinePragma(null);
@ -169,6 +171,9 @@ namespace Microsoft.AspNet.Razor.Generator
public virtual void WriteBooleanLiteral(bool value) public virtual void WriteBooleanLiteral(bool value)
{ {
#if NET45 #if NET45
// ToString does not take a parameter in CoreCLR
// #if'd the entire section because once we transition over to the CodeTree we will not need all this code.
WriteSnippet(value.ToString(CultureInfo.InvariantCulture)); WriteSnippet(value.ToString(CultureInfo.InvariantCulture));
#endif #endif
} }

View File

@ -29,9 +29,6 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
writer.WriteComment(new string('-', 78)) writer.WriteComment(new string('-', 78))
.WriteComment("<auto-generated>") .WriteComment("<auto-generated>")
.WriteComment(" This code was generated by a tool.") .WriteComment(" This code was generated by a tool.")
#if NET45
.WriteComment(" Runtime Version: " + Assembly.GetExecutingAssembly().ImageRuntimeVersion)
#endif
.WriteComment("") .WriteComment("")
.WriteComment(" Changes to this file may cause incorrect behavior and will be lost if") .WriteComment(" Changes to this file may cause incorrect behavior and will be lost if")
.WriteComment(" the code is regenerated.") .WriteComment(" the code is regenerated.")

View File

@ -41,6 +41,8 @@ namespace Microsoft.AspNet.Razor.Generator
public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context) public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context)
{ {
#if NET45 #if NET45
// This code will not be needed once we transition to the CodeTree
if (context.Host.DesignTimeMode) if (context.Host.DesignTimeMode)
{ {
return; // Don't generate anything! return; // Don't generate anything!
@ -55,6 +57,8 @@ namespace Microsoft.AspNet.Razor.Generator
{ {
_isExpression = true; _isExpression = true;
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
generatedCode = context.BuildCodeString(cw => generatedCode = context.BuildCodeString(cw =>
{ {
cw.WriteParameterSeparator(); cw.WriteParameterSeparator();
@ -68,6 +72,8 @@ namespace Microsoft.AspNet.Razor.Generator
context.ExpressionRenderingMode = ExpressionRenderingMode.InjectCode; context.ExpressionRenderingMode = ExpressionRenderingMode.InjectCode;
} }
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
else else
{ {
generatedCode = context.BuildCodeString(cw => generatedCode = context.BuildCodeString(cw =>
@ -108,6 +114,8 @@ namespace Microsoft.AspNet.Razor.Generator
if (_isExpression) if (_isExpression)
{ {
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
generatedCode = context.BuildCodeString(cw => generatedCode = context.BuildCodeString(cw =>
{ {
cw.WriteParameterSeparator(); cw.WriteParameterSeparator();
@ -123,6 +131,8 @@ namespace Microsoft.AspNet.Razor.Generator
context.ExpressionRenderingMode = _oldRenderingMode; context.ExpressionRenderingMode = _oldRenderingMode;
} }
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
else else
{ {
generatedCode = context.BuildCodeString(cw => generatedCode = context.BuildCodeString(cw =>

View File

@ -18,6 +18,8 @@ namespace Microsoft.AspNet.Razor.Generator
public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context) public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context)
{ {
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
if (context.Host.EnableInstrumentation && context.ExpressionRenderingMode == ExpressionRenderingMode.WriteToOutput) if (context.Host.EnableInstrumentation && context.ExpressionRenderingMode == ExpressionRenderingMode.WriteToOutput)
{ {
Span contentSpan = target.Children Span contentSpan = target.Children
@ -69,6 +71,8 @@ namespace Microsoft.AspNet.Razor.Generator
public override void GenerateEndBlockCode(Block target, CodeGeneratorContext context) public override void GenerateEndBlockCode(Block target, CodeGeneratorContext context)
{ {
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
string endBlock = context.BuildCodeString(cw => string endBlock = context.BuildCodeString(cw =>
{ {
if (context.ExpressionRenderingMode == ExpressionRenderingMode.WriteToOutput) if (context.ExpressionRenderingMode == ExpressionRenderingMode.WriteToOutput)
@ -115,6 +119,8 @@ namespace Microsoft.AspNet.Razor.Generator
public override void GenerateCode(Span target, CodeGeneratorContext context) public override void GenerateCode(Span target, CodeGeneratorContext context)
{ {
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
Span sourceSpan = null; Span sourceSpan = null;
if (context.CreateCodeWriter().SupportsMidStatementLinePragmas || context.ExpressionRenderingMode == ExpressionRenderingMode.WriteToOutput) if (context.CreateCodeWriter().SupportsMidStatementLinePragmas || context.ExpressionRenderingMode == ExpressionRenderingMode.WriteToOutput)
{ {

View File

@ -40,6 +40,8 @@ namespace Microsoft.AspNet.Razor.Generator
public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context) public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context)
{ {
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
_writer = context.CreateCodeWriter(); _writer = context.CreateCodeWriter();
string prefix = context.BuildCodeString( string prefix = context.BuildCodeString(
@ -78,6 +80,8 @@ namespace Microsoft.AspNet.Razor.Generator
public override void GenerateEndBlockCode(Block target, CodeGeneratorContext context) public override void GenerateEndBlockCode(Block target, CodeGeneratorContext context)
{ {
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
_statementCollectorToken.Dispose(); _statementCollectorToken.Dispose();
if (HeaderComplete) if (HeaderComplete)
{ {
@ -126,6 +130,8 @@ namespace Microsoft.AspNet.Razor.Generator
} }
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
private void AddStatementToHelper(string statement, CodeLinePragma pragma) private void AddStatementToHelper(string statement, CodeLinePragma pragma)
{ {
if (pragma != null) if (pragma != null)

View File

@ -45,6 +45,8 @@ namespace Microsoft.AspNet.Razor.Generator
ExpressionRenderingMode oldMode = context.ExpressionRenderingMode; ExpressionRenderingMode oldMode = context.ExpressionRenderingMode;
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
context.BufferStatementFragment(context.BuildCodeString(cw => context.BufferStatementFragment(context.BuildCodeString(cw =>
{ {
cw.WriteParameterSeparator(); cw.WriteParameterSeparator();
@ -52,14 +54,17 @@ namespace Microsoft.AspNet.Razor.Generator
cw.WriteLocationTaggedString(Prefix); cw.WriteLocationTaggedString(Prefix);
cw.WriteParameterSeparator(); cw.WriteParameterSeparator();
#endif #endif
if (ValueGenerator != null) if (ValueGenerator != null)
{ {
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
cw.WriteStartMethodInvoke("Tuple.Create", "System.Object", "System.Int32"); cw.WriteStartMethodInvoke("Tuple.Create", "System.Object", "System.Int32");
#endif #endif
context.ExpressionRenderingMode = ExpressionRenderingMode.InjectCode; context.ExpressionRenderingMode = ExpressionRenderingMode.InjectCode;
} }
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
else else
{ {
cw.WriteLocationTaggedString(Value); cw.WriteLocationTaggedString(Value);
@ -74,15 +79,21 @@ namespace Microsoft.AspNet.Razor.Generator
{ {
ValueGenerator.Value.GenerateCode(target, context); ValueGenerator.Value.GenerateCode(target, context);
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
context.FlushBufferedStatement(); context.FlushBufferedStatement();
#endif #endif
context.ExpressionRenderingMode = oldMode; context.ExpressionRenderingMode = oldMode;
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
context.AddStatement(context.BuildCodeString(cw => context.AddStatement(context.BuildCodeString(cw =>
{ {
#endif #endif
chunk.ValueLocation = ValueGenerator.Location; chunk.ValueLocation = ValueGenerator.Location;
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
cw.WriteParameterSeparator(); cw.WriteParameterSeparator();
cw.WriteSnippet(ValueGenerator.Location.AbsoluteIndex.ToString(CultureInfo.CurrentCulture)); cw.WriteSnippet(ValueGenerator.Location.AbsoluteIndex.ToString(CultureInfo.CurrentCulture));
cw.WriteEndMethodInvoke(); cw.WriteEndMethodInvoke();

View File

@ -20,6 +20,8 @@ namespace Microsoft.AspNet.Razor.Generator
return; return;
} }
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
if (context.Host.EnableInstrumentation) if (context.Host.EnableInstrumentation)
{ {
context.AddContextCall(target, context.Host.GeneratedClassContext.BeginContextMethodName, isLiteral: true); context.AddContextCall(target, context.Host.GeneratedClassContext.BeginContextMethodName, isLiteral: true);

View File

@ -77,6 +77,8 @@ namespace Microsoft.AspNet.Razor.Generator
public override void OnComplete() public override void OnComplete()
{ {
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
Context.FlushBufferedStatement(); Context.FlushBufferedStatement();
#endif #endif
} }

View File

@ -10,6 +10,8 @@ namespace Microsoft.AspNet.Razor.Generator
public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context) public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context)
{ {
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
// Flush the buffered statement since we're interrupting it with a comment. // Flush the buffered statement since we're interrupting it with a comment.
if (!String.IsNullOrEmpty(context.CurrentBufferedStatement)) if (!String.IsNullOrEmpty(context.CurrentBufferedStatement))
{ {

View File

@ -36,6 +36,8 @@ namespace Microsoft.AspNet.Razor.Generator
public override void GenerateCode(Span target, CodeGeneratorContext context) public override void GenerateCode(Span target, CodeGeneratorContext context)
{ {
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
var attributeType = new CodeTypeReference(typeof(RazorDirectiveAttribute)); var attributeType = new CodeTypeReference(typeof(RazorDirectiveAttribute));
var attributeDeclaration = new CodeAttributeDeclaration( var attributeDeclaration = new CodeAttributeDeclaration(
attributeType, attributeType,

View File

@ -23,6 +23,8 @@ namespace Microsoft.AspNet.Razor.Generator
return; return;
} }
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
if (!context.Host.DesignTimeMode && String.IsNullOrEmpty(target.Content)) if (!context.Host.DesignTimeMode && String.IsNullOrEmpty(target.Content))
{ {
return; return;

View File

@ -26,6 +26,8 @@ namespace Microsoft.AspNet.Razor.Generator
public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context) public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context)
{ {
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
string startBlock = context.BuildCodeString(cw => string startBlock = context.BuildCodeString(cw =>
{ {
cw.WriteStartMethodInvoke(context.Host.GeneratedClassContext.DefineSectionMethodName); cw.WriteStartMethodInvoke(context.Host.GeneratedClassContext.DefineSectionMethodName);
@ -48,6 +50,8 @@ namespace Microsoft.AspNet.Razor.Generator
public override void GenerateEndBlockCode(Block target, CodeGeneratorContext context) public override void GenerateEndBlockCode(Block target, CodeGeneratorContext context)
{ {
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
string startBlock = context.BuildCodeString(cw => string startBlock = context.BuildCodeString(cw =>
{ {
cw.WriteEndLambdaDelegate(); cw.WriteEndLambdaDelegate();

View File

@ -24,6 +24,8 @@ namespace Microsoft.AspNet.Razor.Generator
public override void GenerateCode(Span target, CodeGeneratorContext context) public override void GenerateCode(Span target, CodeGeneratorContext context)
{ {
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
context.GeneratedClass.BaseTypes.Clear(); context.GeneratedClass.BaseTypes.Clear();
context.GeneratedClass.BaseTypes.Add(new CodeTypeReference(ResolveType(context, BaseType.Trim()))); context.GeneratedClass.BaseTypes.Add(new CodeTypeReference(ResolveType(context, BaseType.Trim())));

View File

@ -24,6 +24,8 @@ namespace Microsoft.AspNet.Razor.Generator
public override void GenerateCode(Span target, CodeGeneratorContext context) public override void GenerateCode(Span target, CodeGeneratorContext context)
{ {
#if NET45 #if NET45
// No CodeDOM
if (!context.Host.DesignTimeMode && !String.IsNullOrEmpty(context.Host.GeneratedClassContext.LayoutPropertyName)) if (!context.Host.DesignTimeMode && !String.IsNullOrEmpty(context.Host.GeneratedClassContext.LayoutPropertyName))
{ {
context.TargetMethod.Statements.Add( context.TargetMethod.Statements.Add(

View File

@ -16,6 +16,8 @@ namespace Microsoft.AspNet.Razor.Generator
public override void GenerateCode(Span target, CodeGeneratorContext context) public override void GenerateCode(Span target, CodeGeneratorContext context)
{ {
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
context.FlushBufferedStatement(); context.FlushBufferedStatement();
string generatedCode = context.BuildCodeString(cw => string generatedCode = context.BuildCodeString(cw =>

View File

@ -20,6 +20,8 @@ namespace Microsoft.AspNet.Razor.Generator
public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context) public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context)
{ {
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
string generatedCode = context.BuildCodeString(cw => string generatedCode = context.BuildCodeString(cw =>
{ {
cw.WriteStartLambdaExpression(ItemParameterName); cw.WriteStartLambdaExpression(ItemParameterName);
@ -47,6 +49,8 @@ namespace Microsoft.AspNet.Razor.Generator
public override void GenerateEndBlockCode(Block target, CodeGeneratorContext context) public override void GenerateEndBlockCode(Block target, CodeGeneratorContext context)
{ {
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
string generatedCode = context.BuildCodeString(cw => string generatedCode = context.BuildCodeString(cw =>
{ {
cw.WriteEndLambdaDelegate(); cw.WriteEndLambdaDelegate();

View File

@ -17,6 +17,8 @@ namespace Microsoft.AspNet.Razor.Generator
public override void GenerateCode(Span target, CodeGeneratorContext context) public override void GenerateCode(Span target, CodeGeneratorContext context)
{ {
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
string generatedCode = context.BuildCodeString(cw => string generatedCode = context.BuildCodeString(cw =>
{ {
cw.WriteSnippet(target.Content); cw.WriteSnippet(target.Content);

View File

@ -39,6 +39,8 @@ namespace Microsoft.AspNet.Razor
public IList<LineMapping> DesignTimeLineMappings { get; private set; } public IList<LineMapping> DesignTimeLineMappings { get; private set; }
#if NET45 #if NET45
// No CodeDOM + This code will not be needed once we transition to the CodeTree
public CodeCompileUnit CCU { get; set; } public CodeCompileUnit CCU { get; set; }
public IDictionary<int, GeneratedCodeMapping> OLDDesignTimeLineMappings { get; set; } public IDictionary<int, GeneratedCodeMapping> OLDDesignTimeLineMappings { get; set; }
#endif #endif

View File

@ -145,7 +145,10 @@ namespace Microsoft.AspNet.Razor.Parser
return CSharpSymbolType.LessThan; return CSharpSymbolType.LessThan;
default: default:
#if NET45 #if NET45
Debug.Fail("FlipBracket must be called with a bracket character"); // No Debug.Fail
Debug.Fail("FlipBracket must be called with a bracket character");
#else
Debug.Assert(false, "FlipBracket must be called with a bracket character");
#endif #endif
return CSharpSymbolType.Unknown; return CSharpSymbolType.Unknown;
} }

View File

@ -90,7 +90,11 @@ namespace Microsoft.AspNet.Razor.Parser
return HtmlSymbolType.OpenAngle; return HtmlSymbolType.OpenAngle;
default: default:
#if NET45 #if NET45
Debug.Fail("FlipBracket must be called with a bracket character"); // No Debug.Fail in CoreCLR
Debug.Fail("FlipBracket must be called with a bracket character");
#else
Debug.Assert(false, "FlipBracket must be called with a bracket character");
#endif #endif
return HtmlSymbolType.Unknown; return HtmlSymbolType.Unknown;
} }

View File

@ -288,7 +288,11 @@ namespace Microsoft.AspNet.Razor.Parser
if (_infiniteLoopGuardCount > InfiniteLoopCountThreshold) if (_infiniteLoopGuardCount > InfiniteLoopCountThreshold)
{ {
#if NET45 #if NET45
// No Debug.Fail in CoreCLR
Debug.Fail("An internal parser error is causing an infinite loop at this location."); Debug.Fail("An internal parser error is causing an infinite loop at this location.");
#else
Debug.Assert(false, "An internal parser error is causing an infinite loop at this location.");
#endif #endif
_terminated = true; _terminated = true;
return true; return true;

View File

@ -34,9 +34,11 @@ namespace Microsoft.AspNet.Razor.Parser
value == '\t' || value == '\t' ||
value == '\u000B' || // Vertical Tab value == '\u000B' || // Vertical Tab
#if NET45 #if NET45
// No GetUnicodeCategory on Char in CoreCLR
Char.GetUnicodeCategory(value) == UnicodeCategory.SpaceSeparator; Char.GetUnicodeCategory(value) == UnicodeCategory.SpaceSeparator;
#else #else
Char.IsSeparator(value); CharUnicodeInfo.GetUnicodeCategory(value) == UnicodeCategory.SpaceSeparator;
#endif #endif
} }
@ -93,9 +95,11 @@ namespace Microsoft.AspNet.Razor.Parser
public static bool IsDecimalDigit(char value) public static bool IsDecimalDigit(char value)
{ {
#if NET45 #if NET45
// No GetUnicodeCategory on Char in CoreCLR
return Char.GetUnicodeCategory(value) == UnicodeCategory.DecimalDigitNumber; return Char.GetUnicodeCategory(value) == UnicodeCategory.DecimalDigitNumber;
#else #else
return Char.IsDigit(value); return CharUnicodeInfo.GetUnicodeCategory(value) == UnicodeCategory.DecimalDigitNumber;
#endif #endif
} }
@ -106,48 +110,57 @@ namespace Microsoft.AspNet.Razor.Parser
public static bool IsLetter(char value) public static bool IsLetter(char value)
{ {
UnicodeCategory cat;
#if NET45 #if NET45
var cat = Char.GetUnicodeCategory(value); // No GetUnicodeCategory on Char in CoreCLR
cat = Char.GetUnicodeCategory(value);
#else
cat = CharUnicodeInfo.GetUnicodeCategory(value);
#endif
return cat == UnicodeCategory.UppercaseLetter return cat == UnicodeCategory.UppercaseLetter
|| cat == UnicodeCategory.LowercaseLetter || cat == UnicodeCategory.LowercaseLetter
|| cat == UnicodeCategory.TitlecaseLetter || cat == UnicodeCategory.TitlecaseLetter
|| cat == UnicodeCategory.ModifierLetter || cat == UnicodeCategory.ModifierLetter
|| cat == UnicodeCategory.OtherLetter || cat == UnicodeCategory.OtherLetter
|| cat == UnicodeCategory.LetterNumber; || cat == UnicodeCategory.LetterNumber;
#else
return Char.IsLetter(value);
#endif
} }
public static bool IsFormatting(char value) public static bool IsFormatting(char value)
{ {
#if NET45 #if NET45
// No GetUnicodeCategory on Char in CoreCLR
return Char.GetUnicodeCategory(value) == UnicodeCategory.Format; return Char.GetUnicodeCategory(value) == UnicodeCategory.Format;
#else #else
return false; // TODO: Make the above work
return CharUnicodeInfo.GetUnicodeCategory(value) == UnicodeCategory.Format;
#endif #endif
} }
public static bool IsCombining(char value) public static bool IsCombining(char value)
{ {
UnicodeCategory cat;
#if NET45 #if NET45
var cat = Char.GetUnicodeCategory(value); // No GetUnicodeCategory on Char in CoreCLR
cat = Char.GetUnicodeCategory(value);
#else
cat = CharUnicodeInfo.GetUnicodeCategory(value);
#endif
return cat == UnicodeCategory.SpacingCombiningMark || cat == UnicodeCategory.NonSpacingMark; return cat == UnicodeCategory.SpacingCombiningMark || cat == UnicodeCategory.NonSpacingMark;
#else
return false; // TODO: Make the above work
#endif
} }
public static bool IsConnecting(char value) public static bool IsConnecting(char value)
{ {
#if NET45 #if NET45
// No GetUnicodeCategory on Char in CoreCLR
return Char.GetUnicodeCategory(value) == UnicodeCategory.ConnectorPunctuation; return Char.GetUnicodeCategory(value) == UnicodeCategory.ConnectorPunctuation;
#else #else
return false; // TODO: Make the above work return CharUnicodeInfo.GetUnicodeCategory(value) == UnicodeCategory.ConnectorPunctuation;
#endif #endif
} }

View File

@ -30,6 +30,8 @@ namespace Microsoft.AspNet.Razor
/// </summary> /// </summary>
public abstract string LanguageName { get; } public abstract string LanguageName { get; }
#if NET45 #if NET45
// No CodeDOM in CoreCLR
/// <summary> /// <summary>
/// The type of the CodeDOM provider for this language /// The type of the CodeDOM provider for this language
/// </summary> /// </summary>

View File

@ -40,6 +40,8 @@ namespace Microsoft.AspNet.Razor
get { return _outputDebuggingEnabled; } get { return _outputDebuggingEnabled; }
} }
#if NET45 #if NET45
// No CodeDOM in CoreCLR
[SuppressMessage("Microsoft.Security", "CA2141:TransparentMethodsMustNotSatisfyLinkDemandsFxCopRule", Justification = "This is debug only")] [SuppressMessage("Microsoft.Security", "CA2141:TransparentMethodsMustNotSatisfyLinkDemandsFxCopRule", Justification = "This is debug only")]
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "This is debug only")] [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "This is debug only")]
[SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.IO.StringWriter.#ctor", Justification = "This is debug only")] [SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.IO.StringWriter.#ctor", Justification = "This is debug only")]

View File

@ -201,6 +201,8 @@ namespace Microsoft.AspNet.Razor
return incomingCodeGenerator; return incomingCodeGenerator;
} }
#if NET45 #if NET45
// No CodeDOM in CoreCLR
/// <summary> /// <summary>
/// Gets the important CodeDOM nodes generated by the code generator and has a chance to add to them. /// Gets the important CodeDOM nodes generated by the code generator and has a chance to add to them.
/// </summary> /// </summary>

View File

@ -167,6 +167,8 @@ namespace Microsoft.AspNet.Razor
generator.DesignTimeMode = Host.DesignTimeMode; generator.DesignTimeMode = Host.DesignTimeMode;
generator.Visit(results); generator.Visit(results);
#if NET45 #if NET45
// No CodeDOM in CoreCLR, this calls into CodeDOM dependent code.
// Post process code // Post process code
Host.PostProcessGeneratedCode(generator.Context); Host.PostProcessGeneratedCode(generator.Context);
#endif #endif
@ -176,6 +178,8 @@ namespace Microsoft.AspNet.Razor
if (Host.DesignTimeMode) if (Host.DesignTimeMode)
{ {
#if NET45 #if NET45
// No CodeDOM in CoreCLR, this calls into CodeDOM dependent code.
designTimeLineMappings = generator.Context.CodeMappings; designTimeLineMappings = generator.Context.CodeMappings;
#endif #endif
} }
@ -187,9 +191,12 @@ namespace Microsoft.AspNet.Razor
return new GeneratorResults(results, builderResult) return new GeneratorResults(results, builderResult)
{ {
#if NET45 #if NET45
// No CodeDOM in CoreCLR, this calls into CodeDOM dependent code.
// Also this code will be removed once we transition into the CodeTree
CCU = generator.Context.CompileUnit, CCU = generator.Context.CompileUnit,
OLDDesignTimeLineMappings = designTimeLineMappings, OLDDesignTimeLineMappings = designTimeLineMappings,
#endif #endif
CT = generator.Context.CodeTreeBuilder.CodeTree CT = generator.Context.CodeTreeBuilder.CodeTree
}; };
} }

View File

@ -6,6 +6,7 @@ using System.Globalization;
namespace Microsoft.AspNet.Razor.Text namespace Microsoft.AspNet.Razor.Text
{ {
#if NET45 #if NET45
// No Serializable attribute in CoreCLR (no need for it anymore?)
[Serializable] [Serializable]
#endif #endif
public struct SourceLocation : IEquatable<SourceLocation>, IComparable<SourceLocation> public struct SourceLocation : IEquatable<SourceLocation>, IComparable<SourceLocation>

View File

@ -11,13 +11,14 @@ namespace Microsoft.AspNet.Razor.Tokenizer
public static bool IsIdentifierStart(char character) public static bool IsIdentifierStart(char character)
{ {
return Char.IsLetter(character) || return Char.IsLetter(character) ||
character == '_' character == '_' ||
#if NET45 #if NET45
|| Char.GetUnicodeCategory(character) == UnicodeCategory.LetterNumber // No GetUnicodeCategory on Char in CoreCLR
Char.GetUnicodeCategory(character) == UnicodeCategory.LetterNumber;
#else #else
|| Char.IsLetterOrDigit(character) CharUnicodeInfo.GetUnicodeCategory(character) == UnicodeCategory.LetterNumber;
#endif #endif
; // Ln
} }
public static bool IsIdentifierPart(char character) public static bool IsIdentifierPart(char character)
@ -39,16 +40,19 @@ namespace Microsoft.AspNet.Razor.Tokenizer
private static bool IsIdentifierPartByUnicodeCategory(char character) private static bool IsIdentifierPartByUnicodeCategory(char character)
{ {
UnicodeCategory category;
#if NET45 #if NET45
UnicodeCategory category = Char.GetUnicodeCategory(character); // No GetUnicodeCategory on Char in CoreCLR
category = Char.GetUnicodeCategory(character);
#else
category = CharUnicodeInfo.GetUnicodeCategory(character);
#endif
return category == UnicodeCategory.NonSpacingMark || // Mn return category == UnicodeCategory.NonSpacingMark || // Mn
category == UnicodeCategory.SpacingCombiningMark || // Mc category == UnicodeCategory.SpacingCombiningMark || // Mc
category == UnicodeCategory.ConnectorPunctuation || // Pc category == UnicodeCategory.ConnectorPunctuation || // Pc
category == UnicodeCategory.Format; // Cf category == UnicodeCategory.Format; // Cf
#else
return false; // TODO: Make the above work
#endif
} }
} }
} }

View File

@ -153,7 +153,11 @@ namespace Microsoft.AspNet.Razor.Tokenizer
return EndSymbol(HtmlSymbolType.DoubleHyphen); return EndSymbol(HtmlSymbolType.DoubleHyphen);
default: default:
#if NET45 #if NET45
Debug.Fail("Unexpected symbol!"); // No Debug.Fail in CoreCLR
Debug.Fail("Unexpected symbol!");
#else
Debug.Assert(false, "Unexpected symbol");
#endif #endif
return EndSymbol(HtmlSymbolType.Unknown); return EndSymbol(HtmlSymbolType.Unknown);
} }

View File

@ -322,7 +322,11 @@ namespace Microsoft.AspNet.Razor.Tokenizer
internal void AssertCurrent(char current) internal void AssertCurrent(char current)
{ {
#if NET45 #if NET45
// No Debug.Assert with this many arguments in CoreCLR
Debug.Assert(CurrentCharacter == current, "CurrentCharacter Assumption violated", "Assumed that the current character would be {0}, but it is actually {1}", current, CurrentCharacter); Debug.Assert(CurrentCharacter == current, "CurrentCharacter Assumption violated", "Assumed that the current character would be {0}, but it is actually {1}", current, CurrentCharacter);
#else
Debug.Assert(CurrentCharacter == current, String.Format("CurrentCharacter Assumption violated. Assumed that the current character would be {0}, but it is actually {1}", current, CurrentCharacter));
#endif #endif
} }