Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ public override string ToString()
if (m_innerExceptions[i] == InnerException)
continue; // Already logged in base.ToString()

text.Append(Environment.NewLine).Append(InnerExceptionPrefix);
text.Append(Environment.NewLineConst + InnerExceptionPrefix);
text.AppendFormat(CultureInfo.InvariantCulture, SR.AggregateException_InnerException, i);
text.Append(m_innerExceptions[i].ToString());
text.Append("<---");
Expand Down
2 changes: 1 addition & 1 deletion src/System.Private.CoreLib/shared/System/AppDomain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public int ExecuteAssemblyByName(string assemblyName, params string?[]? args) =>
public bool IsFinalizingForUnload() => false;

public override string ToString() =>
SR.AppDomain_Name + FriendlyName + Environment.NewLine + SR.AppDomain_NoContextPolicies;
SR.AppDomain_Name + FriendlyName + Environment.NewLineConst + SR.AppDomain_NoContextPolicies;

public static void Unload(AppDomain domain)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public override string Message
string valueMessage = SR.Format(SR.ArgumentOutOfRange_ActualValue, _actualValue);
if (s == null)
return valueMessage;
return s + Environment.NewLine + valueMessage;
return s + Environment.NewLineConst + valueMessage;
}
return s;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,18 @@ public override string ToString()
string s = GetType().ToString() + ": " + Message;

if (!string.IsNullOrEmpty(_fileName))
s += Environment.NewLine + SR.Format(SR.IO_FileName_Name, _fileName);
s += Environment.NewLineConst + SR.Format(SR.IO_FileName_Name, _fileName);

if (InnerException != null)
s = s + InnerExceptionPrefix + InnerException.ToString();
s += InnerExceptionPrefix + InnerException.ToString();

if (StackTrace != null)
s += Environment.NewLine + StackTrace;
s += Environment.NewLineConst + StackTrace;

if (_fusionLog != null)
{
s ??= " ";
s += Environment.NewLine;
s += Environment.NewLine;
s += _fusionLog;
s += Environment.NewLineConst + Environment.NewLineConst + _fusionLog;
}

return s;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public virtual void Fail(string? message, string? detailMessage)

internal void WriteAssert(string stackTrace, string? message, string? detailMessage)
{
WriteLine(SR.DebugAssertBanner + Environment.NewLine
+ SR.DebugAssertShortMessage + Environment.NewLine
+ message + Environment.NewLine
+ SR.DebugAssertLongMessage + Environment.NewLine
+ detailMessage + Environment.NewLine
WriteLine(SR.DebugAssertBanner + Environment.NewLineConst
+ SR.DebugAssertShortMessage + Environment.NewLineConst
+ message + Environment.NewLineConst
+ SR.DebugAssertLongMessage + Environment.NewLineConst
+ detailMessage + Environment.NewLineConst
+ stackTrace);
}

Expand All @@ -52,7 +52,7 @@ public virtual void Write(string? message)
_needIndent = false;
}
WriteCore(message);
if (message.EndsWith(Environment.NewLine))
if (message.EndsWith(Environment.NewLineConst))
{
_needIndent = true;
}
Expand All @@ -61,7 +61,7 @@ public virtual void Write(string? message)

public virtual void WriteLine(string? message)
{
Write(message + Environment.NewLine);
Write(message + Environment.NewLineConst);
}

public virtual void OnIndentLevelChanged(int indentLevel) { }
Expand All @@ -84,7 +84,7 @@ internal DebugAssertException(string? message, string? detailMessage, string? st

s = s.Trim();
if (s.Length > 0)
s += Environment.NewLine;
s += Environment.NewLineConst;

return s;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public override string ToString()
{
sb.Append("<null>");
}
sb.Append(Environment.NewLine);
sb.Append(Environment.NewLineConst);

return sb.ToString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ internal string ToString(TraceFormat traceFormat)
if (fFirstFrame)
fFirstFrame = false;
else
sb.Append(Environment.NewLine);
sb.Append(Environment.NewLineConst);

sb.AppendFormat(CultureInfo.InvariantCulture, " {0} ", word_At);

Expand Down Expand Up @@ -320,14 +320,14 @@ internal string ToString(TraceFormat traceFormat)
// Skip EDI boundary for async
if (sf.IsLastFrameFromForeignExceptionStackTrace && !isAsync)
{
sb.Append(Environment.NewLine);
sb.Append(Environment.NewLineConst);
sb.Append(SR.Exception_EndStackTraceFromPreviousThrow);
}
}
}

if (traceFormat == TraceFormat.TrailingNewLine)
sb.Append(Environment.NewLine);
sb.Append(Environment.NewLineConst);

return sb.ToString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public static string MachineName
}
}

public static string NewLine => "\n";
internal const string NewLineConst = "\n";

private static OperatingSystem GetOSVersion() => GetOperatingSystem(Interop.Sys.GetUnixRelease());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private static string CurrentDirectoryCore

public static string[] GetLogicalDrives() => DriveInfoInternal.GetLogicalDrives();

public static string NewLine => "\r\n";
internal const string NewLineConst = "\r\n";

public static int SystemPageSize
{
Expand Down
2 changes: 2 additions & 0 deletions src/System.Private.CoreLib/shared/System/Environment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public static string GetFolderPath(SpecialFolder folder, SpecialFolderOption opt

public static bool Is64BitOperatingSystem => Is64BitProcess || Is64BitOperatingSystemWhen32BitProcess;

public static string NewLine => NewLineConst;

private static OperatingSystem? s_osVersion;

public static OperatingSystem OSVersion
Expand Down
5 changes: 2 additions & 3 deletions src/System.Private.CoreLib/shared/System/Exception.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,13 @@ public override string ToString()

if (_innerException != null)
{
s = s + Environment.NewLine + InnerExceptionPrefix + _innerException.ToString() + Environment.NewLine +
" " + SR.Exception_EndOfInnerExceptionStack;
s += Environment.NewLineConst + InnerExceptionPrefix + _innerException.ToString() + Environment.NewLineConst + " " + SR.Exception_EndOfInnerExceptionStack;
}

string? stackTrace = StackTrace;
if (stackTrace != null)
{
s += Environment.NewLine + stackTrace;
s += Environment.NewLineConst + stackTrace;
}

return s;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public override string Message
return valueMessage;
}

return s + Environment.NewLine + valueMessage;
return s + Environment.NewLineConst + valueMessage;
}
return s;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5185,7 +5185,7 @@ private static string Hex(string[] strs)
if (s.Length > MaxLineLength || (curLineLength + s.Length + 2) > MaxLineLength)
{
buffer.Append(',');
buffer.Append(Environment.NewLine);
buffer.Append(Environment.NewLineConst);
buffer.Append(' ', NewLinePadding);
curLineLength = 0;
}
Expand All @@ -5202,7 +5202,7 @@ private static string Hex(string[] strs)
s = Hex(strs[strs.Length - 1]);
if (s.Length > MaxLineLength || (curLineLength + s.Length + 6) > MaxLineLength)
{
buffer.Append(Environment.NewLine);
buffer.Append(Environment.NewLineConst);
buffer.Append(' ', NewLinePadding);
}
else
Expand Down
10 changes: 4 additions & 6 deletions src/System.Private.CoreLib/shared/System/IO/FileLoadException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,18 @@ public override string ToString()
string s = GetType().ToString() + ": " + Message;

if (!string.IsNullOrEmpty(FileName))
s += Environment.NewLine + SR.Format(SR.IO_FileName_Name, FileName);
s += Environment.NewLineConst + SR.Format(SR.IO_FileName_Name, FileName);

if (InnerException != null)
s = s + Environment.NewLine + InnerExceptionPrefix + InnerException.ToString();
s += Environment.NewLineConst + InnerExceptionPrefix + InnerException.ToString();

if (StackTrace != null)
s += Environment.NewLine + StackTrace;
s += Environment.NewLineConst + StackTrace;

if (FusionLog != null)
{
s ??= " ";
s += Environment.NewLine;
s += Environment.NewLine;
s += FusionLog;
s += Environment.NewLineConst + Environment.NewLineConst + FusionLog;
}

return s;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,18 @@ public override string ToString()
string s = GetType().ToString() + ": " + Message;

if (!string.IsNullOrEmpty(FileName))
s += Environment.NewLine + SR.Format(SR.IO_FileName_Name, FileName);
s += Environment.NewLineConst + SR.Format(SR.IO_FileName_Name, FileName);

if (InnerException != null)
s = s + Environment.NewLine + InnerExceptionPrefix + InnerException.ToString();
s += Environment.NewLineConst + InnerExceptionPrefix + InnerException.ToString();

if (StackTrace != null)
s += Environment.NewLine + StackTrace;
s += Environment.NewLineConst + StackTrace;

if (FusionLog != null)
{
s ??= " ";
s += Environment.NewLine;
s += Environment.NewLine;
s += FusionLog;
s += Environment.NewLineConst + Environment.NewLineConst + FusionLog;
}
return s;
}
Expand Down
6 changes: 3 additions & 3 deletions src/System.Private.CoreLib/shared/System/IO/TextWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public abstract partial class TextWriter : MarshalByRefObject, IDisposable, IAsy
public static readonly TextWriter Null = new NullTextWriter();

// We don't want to allocate on every TextWriter creation, so cache the char array.
private static readonly char[] s_coreNewLine = Environment.NewLine.ToCharArray();
private static readonly char[] s_coreNewLine = Environment.NewLineConst.ToCharArray();

/// <summary>
/// This is the 'NewLine' property expressed as a char[].
Expand All @@ -34,7 +34,7 @@ public abstract partial class TextWriter : MarshalByRefObject, IDisposable, IAsy
/// as they are shared among many instances of TextWriter.
/// </summary>
protected char[] CoreNewLine = s_coreNewLine;
private string CoreNewLineStr = Environment.NewLine;
private string CoreNewLineStr = Environment.NewLineConst;

// Can be null - if so, ask for the Thread's CurrentCulture every time.
private readonly IFormatProvider? _internalFormatProvider;
Expand Down Expand Up @@ -126,7 +126,7 @@ public virtual string NewLine
{
if (value == null)
{
value = Environment.NewLine;
value = Environment.NewLineConst;
}

CoreNewLineStr = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public override string Message
}

string objectDisposed = SR.Format(SR.ObjectDisposed_ObjectName_Name, name);
return base.Message + Environment.NewLine + objectDisposed;
return base.Message + Environment.NewLineConst + objectDisposed;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private static Version CanonicalizeVersion(this Version version)
new KeyValuePair<char, string>('=', "="),
new KeyValuePair<char, string>('\'', "'"),
new KeyValuePair<char, string>('\"', "\""),
new KeyValuePair<char, string>('n', Environment.NewLine),
new KeyValuePair<char, string>('n', Environment.NewLineConst),
new KeyValuePair<char, string>('t', "\t"),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public FileBasedResourceGroveler(ResourceManager.ResourceManagerMediator mediato
{
// We really don't think this should happen - we always
// expect the neutral locale's resources to be present.
throw new MissingManifestResourceException(SR.MissingManifestResource_NoNeutralDisk + Environment.NewLine + "baseName: " + _mediator.BaseNameField + " locationInfo: " + (_mediator.LocationInfo == null ? "<null>" : _mediator.LocationInfo.FullName) + " fileName: " + _mediator.GetResourceFileName(culture));
throw new MissingManifestResourceException(SR.MissingManifestResource_NoNeutralDisk + Environment.NewLineConst + "baseName: " + _mediator.BaseNameField + " locationInfo: " + (_mediator.LocationInfo == null ? "<null>" : _mediator.LocationInfo.FullName) + " fileName: " + _mediator.GetResourceFileName(culture));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ private void HandleResourceStreamMissing(string fileName)
if (_mediator.MainAssembly == typeof(object).Assembly && _mediator.BaseName.Equals(System.CoreLib.Name))
{
// This would break CultureInfo & all our exceptions.
Debug.Fail("Couldn't get " + System.CoreLib.Name + ResourceManager.ResFileExtension + " from " + System.CoreLib.Name + "'s assembly" + Environment.NewLine + Environment.NewLine + "Are you building the runtime on your machine? Chances are the BCL directory didn't build correctly. Type 'build -c' in the BCL directory. If you get build errors, look at buildd.log. If you then can't figure out what's wrong (and you aren't changing the assembly-related metadata code), ask a BCL dev.\n\nIf you did NOT build the runtime, you shouldn't be seeing this and you've found a bug.");
Debug.Fail("Couldn't get " + System.CoreLib.Name + ResourceManager.ResFileExtension + " from " + System.CoreLib.Name + "'s assembly" + Environment.NewLineConst + Environment.NewLineConst + "Are you building the runtime on your machine? Chances are the BCL directory didn't build correctly. Type 'build -c' in the BCL directory. If you get build errors, look at buildd.log. If you then can't figure out what's wrong (and you aren't changing the assembly-related metadata code), ask a BCL dev.\n\nIf you did NOT build the runtime, you shouldn't be seeing this and you've found a bug.");

// We cannot continue further - simply FailFast.
const string MesgFailFast = System.CoreLib.Name + ResourceManager.ResFileExtension + " couldn't be found! Large parts of the BCL won't work!";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ public override string ToString()
Exception? innerException = InnerException;
if (innerException != null)
{
s.Append(Environment.NewLine).Append(InnerExceptionPrefix).Append(innerException.ToString());
s.Append(Environment.NewLineConst + InnerExceptionPrefix).Append(innerException.ToString());
}

string? stackTrace = StackTrace;
if (stackTrace != null)
s.Append(Environment.NewLine).Append(stackTrace);
s.AppendLine().Append(stackTrace);

return s.ToString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ public override string ToString()

if (!string.IsNullOrEmpty(message))
{
s = s + ": " + message;
s += ": " + message;
}

Exception? innerException = InnerException;
if (innerException != null)
{
s = s + Environment.NewLine + InnerExceptionPrefix + innerException.ToString();
s += Environment.NewLineConst + InnerExceptionPrefix + innerException.ToString();
}

if (StackTrace != null)
s += Environment.NewLine + StackTrace;
s += Environment.NewLineConst + StackTrace;

return s;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ private void ToString(object obj, Action<object, string?> write)

if (i != _attributes.Count - 2)
{
write(obj, Environment.NewLine);
write(obj, Environment.NewLineConst);
}
}
}
Expand All @@ -519,7 +519,7 @@ private void ToString(object obj, Action<object, string?> write)
{
// If we are a single tag with no children, just add the end of tag text.
write(obj, "/>");
write(obj, Environment.NewLine);
write(obj, Environment.NewLineConst);
}
else
{
Expand All @@ -534,7 +534,7 @@ private void ToString(object obj, Action<object, string?> write)
{
ConvertSecurityElementFactories();

write(obj, Environment.NewLine);
write(obj, Environment.NewLineConst);

for (int i = 0; i < _children.Count; ++i)
{
Expand All @@ -546,7 +546,7 @@ private void ToString(object obj, Action<object, string?> write)
write(obj, "</");
write(obj, _tag);
write(obj, ">");
write(obj, Environment.NewLine);
write(obj, Environment.NewLineConst);
}
}

Expand Down
Loading