public CSharpCodeWriter WriteLineNumberDirective(int lineNumber, string file) { if (!string.IsNullOrEmpty(LastWrite) && !LastWrite.EndsWith(Environment.NewLine, StringComparison.Ordinal)) { WriteLine(); } var lineNumberAsString = lineNumber.ToString(CultureInfo.InvariantCulture); return(Write("#line ").Write(lineNumberAsString).Write(" \"").Write(file).WriteLine("\"")); }
/// <summary> /// Writes a <c>#line</c> pragma directive for the line number at the specified <paramref name="location"/>. /// </summary> /// <param name="location">The location to generate the line pragma for.</param> /// <param name="file">The file to generate the line pragma for.</param> /// <returns>The current instance of <see cref="CSharpCodeWriter"/>.</returns> public CSharpCodeWriter WriteLineNumberDirective(SourceLocation location, string file) { if (location.FilePath != null) { file = location.FilePath; } if (!string.IsNullOrEmpty(LastWrite) && !LastWrite.EndsWith(NewLine, StringComparison.Ordinal)) { WriteLine(); } var lineNumberAsString = (location.LineIndex + 1).ToString(CultureInfo.InvariantCulture); return(Write("#line ").Write(lineNumberAsString).Write(" \"").Write(file).WriteLine("\"")); }