-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ILLink: Keep parameter names unless DebuggerSupport is disabled (#105714
) Parameter name trimming is currently the only metadata trimming optimization, but the check covers "all" to include any future metadata trimming optimizations that might impact debuggers.
- Loading branch information
Showing
4 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
...libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/DebuggerSupportFalse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#nullable enable | ||
|
||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Runtime.CompilerServices; | ||
using System.Reflection; | ||
|
||
/// <summary> | ||
/// Ensures setting DebuggerSupport = false causes parameter names to be removed | ||
/// </summary> | ||
class Program | ||
{ | ||
static int Main(string[] args) | ||
{ | ||
// Ensure the method is kept | ||
MethodWithParameter (""); | ||
|
||
// Get parameter name via trim-incompatible reflection | ||
var parameterName = reflectedType.GetMethod("MethodWithParameter")!.GetParameters()[0].Name; | ||
|
||
// Parameter name should be removed | ||
if (!string.IsNullOrEmpty(parameterName)) | ||
return -1; | ||
|
||
return 100; | ||
} | ||
|
||
static Type reflectedType = typeof(Program); | ||
|
||
public static void MethodWithParameter(string parameter) {} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/DebuggerSupportTrue.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#nullable enable | ||
|
||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Runtime.CompilerServices; | ||
using System.Reflection; | ||
|
||
/// <summary> | ||
/// Ensures setting DebuggerSupport = true causes parameter names to be kept | ||
/// </summary> | ||
class Program | ||
{ | ||
static int Main(string[] args) | ||
{ | ||
// Ensure the method is kept | ||
MethodWithParameter (""); | ||
|
||
// Get parameter name via trim-incompatible reflection | ||
var parameterName = reflectedType.GetMethod("MethodWithParameter")!.GetParameters()[0].Name; | ||
|
||
// Parameter name should be kept | ||
if (parameterName != "parameter") | ||
return -1; | ||
|
||
return 100; | ||
} | ||
|
||
static Type reflectedType = typeof(Program); | ||
|
||
public static void MethodWithParameter(string parameter) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters