public void FileName_Set_Get_ReturnsExpected(string value) { var linePragma = new CodeLinePragma(); linePragma.FileName = value; Assert.Equal(value ?? string.Empty, linePragma.FileName); }
public void LinePragma_Set_Get_ReturnsExpected(CodeLinePragma value) { var compileUnit = new CodeSnippetCompileUnit(); compileUnit.LinePragma = value; Assert.Equal(value, compileUnit.LinePragma); }
public void Constructor0() { CodeNamespaceImport cni = new CodeNamespaceImport(); Assert.IsNull(cni.LinePragma, "#1"); Assert.IsNotNull(cni.Namespace, "#2"); Assert.AreEqual(string.Empty, cni.Namespace, "#3"); CodeLinePragma linePragma = new CodeLinePragma("a", 5); cni.LinePragma = linePragma; Assert.IsNotNull(cni.LinePragma, "#4"); Assert.AreSame(linePragma, cni.LinePragma, "#5"); cni.LinePragma = null; Assert.IsNull(cni.LinePragma, "#6"); string ns = "mono"; cni.Namespace = ns; Assert.AreSame(ns, cni.Namespace, "#7"); cni.Namespace = null; Assert.IsNotNull(cni.Namespace, "#8"); Assert.AreEqual(string.Empty, cni.Namespace, "#9"); }
public void LineNumber_Set_Get_ReturnsExpected(int value) { var linePragma = new CodeLinePragma(); linePragma.LineNumber = value; Assert.Equal(value, linePragma.LineNumber); }
public void Constructor0() { CodeSnippetStatement css = new CodeSnippetStatement(); Assert.IsNull(css.LinePragma, "#1"); Assert.IsNotNull(css.Value, "#2"); Assert.AreEqual(string.Empty, css.Value, "#3"); #if NET_2_0 Assert.IsNotNull(css.StartDirectives, "#4"); Assert.AreEqual(0, css.StartDirectives.Count, "#5"); Assert.IsNotNull(css.EndDirectives, "#6"); Assert.AreEqual(0, css.EndDirectives.Count, "#7"); #endif Assert.IsNotNull(css.UserData, "#8"); Assert.AreEqual(typeof(ListDictionary), css.UserData.GetType(), "#9"); Assert.AreEqual(0, css.UserData.Count, "#10"); css.Value = null; Assert.IsNotNull(css.Value, "#11"); Assert.AreEqual(string.Empty, css.Value, "#12"); CodeLinePragma clp = new CodeLinePragma("mono", 10); css.LinePragma = clp; Assert.IsNotNull(css.LinePragma, "#13"); Assert.AreSame(clp, css.LinePragma, "#14"); css.LinePragma = null; Assert.IsNull(css.LinePragma, "#15"); }
public void Ctor_Default() { var linePragma = new CodeLinePragma(); Assert.Empty(linePragma.FileName); Assert.Equal(0, linePragma.LineNumber); }
public static CodeConstructor Constructor( MemberAttributes attributes, CodeParameterDeclarationExpression[] parameters, CodeExpression[] chainedConstructorArgs, CodeExpression[] baseConstructorArgs, CodeStatement[] statements, CodeCommentStatement[] comments, CodeAttributeDeclaration[] customAttributes, CodeDirective[] startDirectives, CodeDirective[] endDirectives, CodeLinePragma linePragma) { var result = new CodeConstructor(); result.Attributes = attributes; result.Parameters.AddRange(parameters); result.ChainedConstructorArgs.AddRange(chainedConstructorArgs); result.BaseConstructorArgs.AddRange(baseConstructorArgs); result.Statements.AddRange(statements); result.Comments.AddRange(comments); result.CustomAttributes.AddRange(customAttributes); result.StartDirectives.AddRange(startDirectives); result.EndDirectives.AddRange(endDirectives); result.LinePragma = linePragma; return(result); }
public void LinePragma_Set_Get_ReturnsExpected(CodeLinePragma value) { var import = new CodeNamespaceImport(); import.LinePragma = value; Assert.Equal(value, import.LinePragma); }
public static CodeMemberProperty MemberProperty( CodeTypeReference type, string name, MemberAttributes attributes, CodeParameterDeclarationExpression[] parameters, CodeStatement[] getStatements, CodeStatement[] setStatements, CodeTypeReference[] implementationTypes, CodeTypeReference privateImplementationType, CodeCommentStatement[] comments, CodeAttributeDeclaration[] customAttributes, CodeDirective[] startDirectives, CodeDirective[] endDirectives, CodeLinePragma linePragma) { var result = new CodeMemberProperty(); result.Type = type; result.Name = name; result.Attributes = attributes; result.Parameters.AddRange(parameters); result.GetStatements.AddRange(getStatements); result.SetStatements.AddRange(setStatements); result.ImplementationTypes.AddRange(implementationTypes); result.PrivateImplementationType = privateImplementationType; result.Comments.AddRange(comments); result.CustomAttributes.AddRange(customAttributes); result.StartDirectives.AddRange(startDirectives); result.EndDirectives.AddRange(endDirectives); result.LinePragma = linePragma; return(result); }
public void Constructor0() { CodeGotoStatement cgs = new CodeGotoStatement(); Assert.IsNull(cgs.Label, "#1"); Assert.IsNotNull(cgs.StartDirectives, "#2"); Assert.AreEqual(0, cgs.StartDirectives.Count, "#3"); Assert.IsNotNull(cgs.EndDirectives, "#4"); Assert.AreEqual(0, cgs.EndDirectives.Count, "#5"); Assert.IsNotNull(cgs.UserData, "#6"); Assert.AreEqual(typeof(ListDictionary), cgs.UserData.GetType(), "#7"); Assert.AreEqual(0, cgs.UserData.Count, "#8"); Assert.IsNull(cgs.LinePragma, "#9"); CodeLinePragma clp = new CodeLinePragma("mono", 10); cgs.LinePragma = clp; Assert.IsNotNull(cgs.LinePragma, "#10"); Assert.AreSame(clp, cgs.LinePragma, "#11"); cgs.LinePragma = null; Assert.IsNull(cgs.LinePragma, "#12"); string label = "mono"; cgs.Label = label; Assert.AreSame(label, cgs.Label, "#13"); }
private void CompileSourceCode() { // Return if there is nothing to compile if (_sourceString == null) { return; } // Put in some context so that the file can be debugged. CodeLinePragma linePragma = new CodeLinePragma(_inputFile, _lineNumber); try { // Compile the string, and get a type _compiledType = _sourceCompiler.CompileSourceStringIntoType(_sourceString, _className, linePragma, _linkedAssemblies, _compilerType, _compilParams); } catch { // Throw a specific error if the type was not found if (_sourceCompiler.TypeNotFoundInAssembly) { throw new HttpParseException( HttpRuntime.FormatResourceString(SR.Type_not_found_in_src, _className), null, _inputFile, _sourceString, _lineNumber); } else { // Just rethrow throw; } } }
protected internal virtual void VisitSpan(NamespaceImportSpan span) { string ns = span.Namespace; // If the first character is whitespace, yank it out since the CodeDOM will add one space if (ns.Length > 0 && Char.IsWhiteSpace(ns[0])) { ns = ns.Substring(1); } // Check for an existing import CodeNamespaceImport existingImport = GeneratedNamespace.Imports .OfType <CodeNamespaceImport>() .FirstOrDefault(import => String.Equals(import.Namespace, span.Namespace.Trim(), StringComparison.Ordinal)); CodeLinePragma pragma = CreateLinePragma(span.Start, 0, span.Content.Length); if (existingImport != null && existingImport.LinePragma == null) { existingImport.LinePragma = pragma; existingImport.Namespace = ns; } else { // Build the import GeneratedNamespace.Imports.Add(new CodeNamespaceImport(ns) { LinePragma = pragma }); } }
private void LinePragmaEnd(CodeLinePragma pragma) { if (pragma != null) { GenerateLinePragmaEnd(pragma); } }
// Helper methods for line pragmas. private void LinePragmaStart(CodeLinePragma pragma) { if (pragma != null) { GenerateLinePragmaStart(pragma); } }
public StructureBuilder(NamespaceBuilder ns, CodeLinePragma loc, TypeAttributes attr) : base(BundleManagerBase.DefaultStructureClass, ns, loc, attr) { BaseClass = new UserType (typeof (StructureTemplate)); ns.SetUserParams (this); }
public FieldInfo(int idx, UserType type, string name, CodeLinePragma line) { Idx = idx; Type = type; Name = name; Line = line; }
public void Ctor_String_Int(string fileName, int lineNumber) { var linePragma = new CodeLinePragma(fileName, lineNumber); Assert.Equal(fileName ?? string.Empty, linePragma.FileName); Assert.Equal(lineNumber, linePragma.LineNumber); }
public void CodeDomSerializerException_Constructor_Message_Pragma() { var pragma = new CodeLinePragma(); var underTest = new CodeDomSerializerException("message", pragma); Assert.NotNull(underTest); Assert.Equal(pragma, underTest.LinePragma); }
public MetaRuleBuilder(string name, NamespaceBuilder ns, CodeLinePragma loc, TypeAttributes attr) { rb = new RuleBuilder(name, ns, loc, attr); tmpl = new RuleTemplateBuilder(name + "RTemplate", rb, ns, loc, attr); ns.AddMetaRule(this); BaseClass = RuleType; }
public TheResult(string name, NamespaceBuilder ns, string ename, CodeLinePragma loc, TypeAttributes attr) : base(name, ns, loc, attr) { etype = new UserType(ename); BaseClass = new UserType(typeof(EnumResult <>)); BaseClass.AddTypeArgument(etype); }
public static CodeNamespaceImport NamespaceImport( string nameSpace, CodeLinePragma linePragma) { var result = new CodeNamespaceImport(nameSpace); result.LinePragma = linePragma; return(result); }
public void Constructor1_Deny_Unrestricted() { CodeLinePragma clp = new CodeLinePragma("filename", Int32.MaxValue); Assert.AreEqual("filename", clp.FileName, "FileName"); clp.FileName = String.Empty; Assert.AreEqual(Int32.MaxValue, clp.LineNumber, "LineNumber"); clp.LineNumber = 0; }
protected override void GenerateLinePragmaStart(CodeLinePragma e) { Output.WriteLine(); Output.Write("#ExternalSource(\""); Output.Write(e.FileName); Output.Write(","); Output.Write(e.LineNumber); Output.WriteLine(")"); }
public void LinePragma_Set_Get_ReturnsExpected(CodeLinePragma value) { CodeStatement statement = new T() { LinePragma = value }; Assert.Equal(value, statement.LinePragma); }
public void Constructor0_Deny_Unrestricted() { CodeLinePragma clp = new CodeLinePragma(); Assert.AreEqual(String.Empty, clp.FileName, "FileName"); clp.FileName = "filename"; Assert.AreEqual(0, clp.LineNumber, "LineNumber"); clp.LineNumber = Int32.MinValue; }
public EnumResultBuilder(string name, NamespaceBuilder ns, CodeLinePragma loc, TypeAttributes attr) { if (name == null) { throw new ArgumentNullException(); } enumer = new TheEnum(name, ns, loc, attr); result = new TheResult(name + "Result", ns, name, loc, attr); }
public void LinePragma_SetNonNull_Get_ReturnsExpected() { CodeLinePragma pragma = new CodeLinePragma("FileName", 1); CodeTypeMember member = new T() { LinePragma = pragma }; Assert.Equal(pragma, member.LinePragma); }
public override void GenerateCode(Span target, CodeGeneratorContext context) { // Build the string string code = Prefix + target.Content + ";"; // Calculate the line pragma including information about where the user-specified code starts and ends (for editors) CodeLinePragma pragma = context.GenerateLinePragma(target, Prefix.Length, target.Content.Length); // Add the statement context.AddStatement(code, pragma); }
public virtual void WriteLinePragma(CodeLinePragma pragma) { if (pragma == null) { WriteLinePragma(null, null); } else { WriteLinePragma(pragma.LineNumber, pragma.FileName); } }
private void AddStatementToHelper(string statement, CodeLinePragma pragma) { if (pragma != null) { _writer.WriteLinePragma(pragma); } _writer.WriteSnippet(statement); if (pragma != null) { _writer.WriteLinePragma(); } }
protected override void GenerateLinePragmaStart(CodeLinePragma e) { Output.WriteLine(); Output.Write("#ExternalSource(\""); Output.Write(e.FileName); Output.Write(","); Output.Write(e.LineNumber); Output.WriteLine(")"); }
protected override void GenerateLinePragmaEnd(CodeLinePragma e) { Output.WriteLine(); Output.WriteLine("#End ExternalSource"); }
protected abstract void GenerateLinePragmaStart(CodeLinePragma e);
protected abstract void GenerateLinePragmaEnd(CodeLinePragma e);
private void ValidateLinePragmaStart(CodeLinePragma e) { }
public void Ctor_Default() { var linePragma = new CodeLinePragma(); Assert.Empty(linePragma.FileName); Assert.Equal(0, linePragma.LineNumber); }
private void LinePragmaEnd(CodeLinePragma pragma) { if(pragma != null) { GenerateLinePragmaEnd(pragma); } }
public void FileName_Set_Get_ReturnsExpected(string value) { var linePragma = new CodeLinePragma(); linePragma.FileName = value; Assert.Equal(value ?? string.Empty, linePragma.FileName); }
// Helper methods for line pragmas. private void LinePragmaStart(CodeLinePragma pragma) { if(pragma != null) { GenerateLinePragmaStart(pragma); } }
protected override void GenerateLinePragmaStart(CodeLinePragma e) { Output.WriteLine(); Output.WriteLine("#line {0} \"{1}\"", e.LineNumber, e.FileName); }
protected override void GenerateLinePragmaEnd(CodeLinePragma e) { Output.WriteLine(); Output.WriteLine("#line default"); }
public void LineNumber_Set_Get_ReturnsExpected(int value) { var linePragma = new CodeLinePragma(); linePragma.LineNumber = value; Assert.Equal(value, linePragma.LineNumber); }
public void Ctor_String_Int(string fileName, int lineNumber) { var linePragma = new CodeLinePragma(fileName, lineNumber); Assert.Equal(fileName ?? string.Empty, linePragma.FileName); Assert.Equal(lineNumber, linePragma.LineNumber); }