diff --git a/src/System.Private.CoreLib/shared/System/AggregateException.cs b/src/System.Private.CoreLib/shared/System/AggregateException.cs index c9d11cbbd1a3..46baebfddd6e 100644 --- a/src/System.Private.CoreLib/shared/System/AggregateException.cs +++ b/src/System.Private.CoreLib/shared/System/AggregateException.cs @@ -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("<---"); diff --git a/src/System.Private.CoreLib/shared/System/AppDomain.cs b/src/System.Private.CoreLib/shared/System/AppDomain.cs index fc255c78dcff..340b34d942fc 100644 --- a/src/System.Private.CoreLib/shared/System/AppDomain.cs +++ b/src/System.Private.CoreLib/shared/System/AppDomain.cs @@ -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) { diff --git a/src/System.Private.CoreLib/shared/System/ArgumentOutOfRangeException.cs b/src/System.Private.CoreLib/shared/System/ArgumentOutOfRangeException.cs index daf4f556ea43..cba74213d200 100644 --- a/src/System.Private.CoreLib/shared/System/ArgumentOutOfRangeException.cs +++ b/src/System.Private.CoreLib/shared/System/ArgumentOutOfRangeException.cs @@ -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; } diff --git a/src/System.Private.CoreLib/shared/System/BadImageFormatException.cs b/src/System.Private.CoreLib/shared/System/BadImageFormatException.cs index 246fe817c7d0..c241eed32df5 100644 --- a/src/System.Private.CoreLib/shared/System/BadImageFormatException.cs +++ b/src/System.Private.CoreLib/shared/System/BadImageFormatException.cs @@ -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; diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/DebugProvider.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/DebugProvider.cs index e27a6d3dc8de..cf4dfe1effdb 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/DebugProvider.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/DebugProvider.cs @@ -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); } @@ -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; } @@ -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) { } @@ -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; } diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/StackFrame.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/StackFrame.cs index 02c687c0d8d0..087a7402e4b9 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/StackFrame.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/StackFrame.cs @@ -240,7 +240,7 @@ public override string ToString() { sb.Append(""); } - sb.Append(Environment.NewLine); + sb.Append(Environment.NewLineConst); return sb.ToString(); } diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/StackTrace.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/StackTrace.cs index e33c68763f6d..aaabf2076e2a 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/StackTrace.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/StackTrace.cs @@ -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); @@ -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(); } diff --git a/src/System.Private.CoreLib/shared/System/Environment.Unix.cs b/src/System.Private.CoreLib/shared/System/Environment.Unix.cs index 47899cac108b..208a999f3360 100644 --- a/src/System.Private.CoreLib/shared/System/Environment.Unix.cs +++ b/src/System.Private.CoreLib/shared/System/Environment.Unix.cs @@ -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()); diff --git a/src/System.Private.CoreLib/shared/System/Environment.Windows.cs b/src/System.Private.CoreLib/shared/System/Environment.Windows.cs index e2b0918553db..157e527545f4 100644 --- a/src/System.Private.CoreLib/shared/System/Environment.Windows.cs +++ b/src/System.Private.CoreLib/shared/System/Environment.Windows.cs @@ -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 { diff --git a/src/System.Private.CoreLib/shared/System/Environment.cs b/src/System.Private.CoreLib/shared/System/Environment.cs index 045baf5db85e..ea04f1000c77 100644 --- a/src/System.Private.CoreLib/shared/System/Environment.cs +++ b/src/System.Private.CoreLib/shared/System/Environment.cs @@ -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 diff --git a/src/System.Private.CoreLib/shared/System/Exception.cs b/src/System.Private.CoreLib/shared/System/Exception.cs index 5e4f07890106..5d38412538f6 100644 --- a/src/System.Private.CoreLib/shared/System/Exception.cs +++ b/src/System.Private.CoreLib/shared/System/Exception.cs @@ -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; diff --git a/src/System.Private.CoreLib/shared/System/Globalization/CultureNotFoundException.cs b/src/System.Private.CoreLib/shared/System/Globalization/CultureNotFoundException.cs index 8e584018251f..5869b6ae51d5 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/CultureNotFoundException.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/CultureNotFoundException.cs @@ -95,7 +95,7 @@ public override string Message return valueMessage; } - return s + Environment.NewLine + valueMessage; + return s + Environment.NewLineConst + valueMessage; } return s; } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeParse.cs b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeParse.cs index 664abfd9e787..728d9e4dd2a6 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeParse.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeParse.cs @@ -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; } @@ -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 diff --git a/src/System.Private.CoreLib/shared/System/IO/FileLoadException.cs b/src/System.Private.CoreLib/shared/System/IO/FileLoadException.cs index b2c118920ec9..f7ef7c4c050e 100644 --- a/src/System.Private.CoreLib/shared/System/IO/FileLoadException.cs +++ b/src/System.Private.CoreLib/shared/System/IO/FileLoadException.cs @@ -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; diff --git a/src/System.Private.CoreLib/shared/System/IO/FileNotFoundException.cs b/src/System.Private.CoreLib/shared/System/IO/FileNotFoundException.cs index 33ca28ee19a7..48c513b7f374 100644 --- a/src/System.Private.CoreLib/shared/System/IO/FileNotFoundException.cs +++ b/src/System.Private.CoreLib/shared/System/IO/FileNotFoundException.cs @@ -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; } diff --git a/src/System.Private.CoreLib/shared/System/IO/TextWriter.cs b/src/System.Private.CoreLib/shared/System/IO/TextWriter.cs index 6a8ef286f37e..8263072b14e4 100644 --- a/src/System.Private.CoreLib/shared/System/IO/TextWriter.cs +++ b/src/System.Private.CoreLib/shared/System/IO/TextWriter.cs @@ -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(); /// /// This is the 'NewLine' property expressed as a char[]. @@ -34,7 +34,7 @@ public abstract partial class TextWriter : MarshalByRefObject, IDisposable, IAsy /// as they are shared among many instances of TextWriter. /// 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; @@ -126,7 +126,7 @@ public virtual string NewLine { if (value == null) { - value = Environment.NewLine; + value = Environment.NewLineConst; } CoreNewLineStr = value; diff --git a/src/System.Private.CoreLib/shared/System/ObjectDisposedException.cs b/src/System.Private.CoreLib/shared/System/ObjectDisposedException.cs index 09d43ed6667b..41441c0e48c1 100644 --- a/src/System.Private.CoreLib/shared/System/ObjectDisposedException.cs +++ b/src/System.Private.CoreLib/shared/System/ObjectDisposedException.cs @@ -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; } } diff --git a/src/System.Private.CoreLib/shared/System/Reflection/AssemblyNameFormatter.cs b/src/System.Private.CoreLib/shared/System/Reflection/AssemblyNameFormatter.cs index 7c25ebea653e..09585f8d58f1 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/AssemblyNameFormatter.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/AssemblyNameFormatter.cs @@ -147,7 +147,7 @@ private static Version CanonicalizeVersion(this Version version) new KeyValuePair('=', "="), new KeyValuePair('\'', "'"), new KeyValuePair('\"', "\""), - new KeyValuePair('n', Environment.NewLine), + new KeyValuePair('n', Environment.NewLineConst), new KeyValuePair('t', "\t"), }; } diff --git a/src/System.Private.CoreLib/shared/System/Resources/FileBasedResourceGroveler.cs b/src/System.Private.CoreLib/shared/System/Resources/FileBasedResourceGroveler.cs index bfe217975a4d..27af1ffae66f 100644 --- a/src/System.Private.CoreLib/shared/System/Resources/FileBasedResourceGroveler.cs +++ b/src/System.Private.CoreLib/shared/System/Resources/FileBasedResourceGroveler.cs @@ -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 ? "" : _mediator.LocationInfo.FullName) + " fileName: " + _mediator.GetResourceFileName(culture)); + throw new MissingManifestResourceException(SR.MissingManifestResource_NoNeutralDisk + Environment.NewLineConst + "baseName: " + _mediator.BaseNameField + " locationInfo: " + (_mediator.LocationInfo == null ? "" : _mediator.LocationInfo.FullName) + " fileName: " + _mediator.GetResourceFileName(culture)); } } } diff --git a/src/System.Private.CoreLib/shared/System/Resources/ManifestBasedResourceGroveler.cs b/src/System.Private.CoreLib/shared/System/Resources/ManifestBasedResourceGroveler.cs index 60b02909c772..982d5007cf33 100644 --- a/src/System.Private.CoreLib/shared/System/Resources/ManifestBasedResourceGroveler.cs +++ b/src/System.Private.CoreLib/shared/System/Resources/ManifestBasedResourceGroveler.cs @@ -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!"; diff --git a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/COMException.cs b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/COMException.cs index 1b66bb6379a4..6b22d0263133 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/COMException.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/COMException.cs @@ -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(); } diff --git a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/ExternalException.cs b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/ExternalException.cs index f04fa6fd5c0d..b9bc042986e0 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/ExternalException.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/ExternalException.cs @@ -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; } diff --git a/src/System.Private.CoreLib/shared/System/Security/SecurityElement.cs b/src/System.Private.CoreLib/shared/System/Security/SecurityElement.cs index d1556b96580a..a15560b83ff3 100644 --- a/src/System.Private.CoreLib/shared/System/Security/SecurityElement.cs +++ b/src/System.Private.CoreLib/shared/System/Security/SecurityElement.cs @@ -510,7 +510,7 @@ private void ToString(object obj, Action write) if (i != _attributes.Count - 2) { - write(obj, Environment.NewLine); + write(obj, Environment.NewLineConst); } } } @@ -519,7 +519,7 @@ private void ToString(object obj, Action 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 { @@ -534,7 +534,7 @@ private void ToString(object obj, Action write) { ConvertSecurityElementFactories(); - write(obj, Environment.NewLine); + write(obj, Environment.NewLineConst); for (int i = 0; i < _children.Count; ++i) { @@ -546,7 +546,7 @@ private void ToString(object obj, Action write) write(obj, ""); - write(obj, Environment.NewLine); + write(obj, Environment.NewLineConst); } } diff --git a/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs b/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs index 6dca047a27ef..82d75fb53f57 100644 --- a/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs +++ b/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs @@ -982,12 +982,12 @@ private StringBuilder AppendCore(StringBuilder value, int startIndex, int count) return this; } - public StringBuilder AppendLine() => Append(Environment.NewLine); + public StringBuilder AppendLine() => Append(Environment.NewLineConst); public StringBuilder AppendLine(string? value) { Append(value); - return Append(Environment.NewLine); + return Append(Environment.NewLineConst); } public void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count) diff --git a/src/System.Private.CoreLib/src/Internal/Console.cs b/src/System.Private.CoreLib/src/Internal/Console.cs index 3f8da45d6752..f501d1f30c65 100644 --- a/src/System.Private.CoreLib/src/Internal/Console.cs +++ b/src/System.Private.CoreLib/src/Internal/Console.cs @@ -28,9 +28,9 @@ public static unsafe void Write(string s) } public static void WriteLine(string? s) => - Write(s + Environment.NewLine); + Write(s + Environment.NewLineConst); public static void WriteLine() => - Write(Environment.NewLine); + Write(Environment.NewLineConst); } } diff --git a/src/System.Private.CoreLib/src/System/Exception.CoreCLR.cs b/src/System.Private.CoreLib/src/System/Exception.CoreCLR.cs index 5b81703c448a..8bffa790a862 100644 --- a/src/System.Private.CoreLib/src/System/Exception.CoreCLR.cs +++ b/src/System.Private.CoreLib/src/System/Exception.CoreCLR.cs @@ -236,7 +236,7 @@ internal void InternalPreserveStackTrace() if (!string.IsNullOrEmpty(tmpStackTraceString)) { - _remoteStackTraceString = tmpStackTraceString + Environment.NewLine; + _remoteStackTraceString = tmpStackTraceString + Environment.NewLineConst; } _stackTrace = null; diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs index 802c3eceaf90..0e509681f204 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs @@ -460,7 +460,7 @@ public override string ToString() sb.Append("Name: ").Append(m_strName).AppendLine(" "); sb.Append("Attributes: ").Append((int)m_iAttributes).AppendLine(); sb.Append("Method Signature: ").Append(GetMethodSignature()).AppendLine(); - sb.Append(Environment.NewLine); + sb.AppendLine(); return sb.ToString(); }