Skip to content

Commit 456e1fe

Browse files
authored
Mark CoreLib Internal.Console methods with NoInline (#115282)
- Matches public System.Console - Makes optimized code easier to understand when one uses WriteLine debugging
1 parent 712b3fc commit 456e1fe

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed

src/libraries/System.Private.CoreLib/src/Internal/Console.Android.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,22 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5+
using System.Runtime.CompilerServices;
56
using System.Runtime.InteropServices;
67

78
namespace Internal
89
{
910
public static partial class Console
1011
{
12+
[MethodImplAttribute(MethodImplOptions.NoInlining)]
1113
public static unsafe void Write(string s)
1214
{
1315
Interop.Logcat.AndroidLogPrint(Interop.Logcat.LogLevel.Debug, "DOTNET", s ?? string.Empty);
1416
}
1517

1618
public static partial class Error
1719
{
20+
[MethodImplAttribute(MethodImplOptions.NoInlining)]
1821
public static unsafe void Write(string s)
1922
{
2023
Interop.Logcat.AndroidLogPrint(Interop.Logcat.LogLevel.Error, "DOTNET", s ?? string.Empty);

src/libraries/System.Private.CoreLib/src/Internal/Console.Unix.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5+
using System.Runtime.CompilerServices;
56
using System.Text;
67

78
namespace Internal
89
{
910
public static partial class Console
1011
{
12+
[MethodImplAttribute(MethodImplOptions.NoInlining)]
1113
public static unsafe void Write(string s)
1214
{
1315
byte[] bytes = Encoding.UTF8.GetBytes(s);
@@ -19,6 +21,7 @@ public static unsafe void Write(string s)
1921

2022
public static partial class Error
2123
{
24+
[MethodImplAttribute(MethodImplOptions.NoInlining)]
2225
public static unsafe void Write(string s)
2326
{
2427
byte[] bytes = Encoding.UTF8.GetBytes(s);

src/libraries/System.Private.CoreLib/src/Internal/Console.Windows.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,22 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5+
using System.Runtime.CompilerServices;
56
using System.Text;
67

78
namespace Internal
89
{
910
public static partial class Console
1011
{
12+
[MethodImplAttribute(MethodImplOptions.NoInlining)]
1113
public static void Write(string s)
1214
{
1315
WriteCore(Interop.Kernel32.GetStdHandle(Interop.Kernel32.HandleTypes.STD_OUTPUT_HANDLE), s);
1416
}
1517

1618
public static partial class Error
1719
{
20+
[MethodImplAttribute(MethodImplOptions.NoInlining)]
1821
public static void Write(string s)
1922
{
2023
WriteCore(Interop.Kernel32.GetStdHandle(Interop.Kernel32.HandleTypes.STD_ERROR_HANDLE), s);

src/libraries/System.Private.CoreLib/src/Internal/Console.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5+
using System.Runtime.CompilerServices;
56

67
namespace Internal
78
{
@@ -12,14 +13,17 @@ namespace Internal
1213

1314
public static partial class Console
1415
{
16+
[MethodImplAttribute(MethodImplOptions.NoInlining)]
1517
public static void WriteLine(string? s) =>
1618
Write(s + Environment.NewLineConst);
1719

20+
[MethodImplAttribute(MethodImplOptions.NoInlining)]
1821
public static void WriteLine() =>
1922
Write(Environment.NewLineConst);
2023

2124
public static partial class Error
2225
{
26+
[MethodImplAttribute(MethodImplOptions.NoInlining)]
2327
public static void WriteLine() =>
2428
Write(Environment.NewLineConst);
2529
}

src/libraries/System.Private.CoreLib/src/Internal/Console.iOS.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5+
using System.Runtime.CompilerServices;
56
using System.Text;
67

78
namespace Internal
89
{
910
public static partial class Console
1011
{
12+
[MethodImplAttribute(MethodImplOptions.NoInlining)]
1113
public static unsafe void Write(string s)
1214
{
1315
fixed (char* ptr = s)
@@ -17,6 +19,7 @@ public static unsafe void Write(string s)
1719
}
1820
public static partial class Error
1921
{
22+
[MethodImplAttribute(MethodImplOptions.NoInlining)]
2023
public static unsafe void Write(string s)
2124
{
2225
fixed (char* ptr = s)

0 commit comments

Comments
 (0)