Skip to content

Commit

Permalink
Remove unnecessary pragmas (#55810)
Browse files Browse the repository at this point in the history
* Remove unnecessary pragmas

...now that dotnet/linker#2715 has been fixed.

* Remove some additional suppressions

* Fix build

* Add RequiresDynamicCode attribute because we are using MakeGenericMethod on a Type that may be a value type.

---------

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
  • Loading branch information
amcasey and eerhardt authored May 28, 2024
1 parent 83aa6b1 commit f8c9806
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 11 deletions.
3 changes: 1 addition & 2 deletions src/Http/Http.Results/src/ResultsOfTHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ internal static class ResultsOfTHelper
}
}

// TODO: Remove IL3050 suppress when https://github.com/dotnet/linker/issues/2715 is complete.
[UnconditionalSuppressMessage("AOT", "IL3050", Justification = "Validated with IsDynamicCodeSupported check.")]
[RequiresDynamicCode("The native code for the PopulateMetadata<TTarget> instantiation might not be available at runtime.")]
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2060:MakeGenericMethod",
Justification = "The call to MakeGenericMethod is safe due to the fact that PopulateMetadata<TTarget> does not have a DynamicallyAccessMembers attribute and TTarget is annotated to preserve all methods to preserve the PopulateMetadata method.")]
static void InvokeGenericPopulateMetadata(object[] parameters)
Expand Down
3 changes: 0 additions & 3 deletions src/Http/Routing/src/Matching/JumpTableBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Text;

Expand Down Expand Up @@ -89,8 +88,6 @@ public static JumpTable Build(int defaultDestination, int exitDestination, (stri
// Use the ILEmitTrieJumpTable if the IL is going to be compiled (not interpreted)
return MakeILEmitTrieJumpTableIfSupported(defaultDestination, exitDestination, pathEntries, fallback);

// TODO: This suppression can be removed when https://github.com/dotnet/linker/issues/2715 is complete.
[UnconditionalSuppressMessage("AOT", "IL3050", Justification = "Guarded by IsDynamicCodeCompiled")]
static JumpTable MakeILEmitTrieJumpTableIfSupported(int defaultDestination, int exitDestination, (string text, int destination)[] pathEntries, JumpTable fallback)
{
// ILEmitTrieJumpTable use IL emit to generate a custom, high-performance jump table.
Expand Down
6 changes: 0 additions & 6 deletions src/Shared/PropertyHelper/PropertyHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,6 @@ public static PropertyHelper[] GetVisibleProperties(
// MakeGenericMethod + value type requires IsDynamicCodeSupported to be true.
if (RuntimeFeature.IsDynamicCodeSupported)
{
// TODO: Remove disable when https://github.com/dotnet/linker/issues/2715 is complete.
#pragma warning disable IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
// Instance methods in the CLR can be turned into static methods where the first parameter
// is open over "target". This parameter is always passed by reference, so we have a code
// path for value types and a code path for reference types.
Expand All @@ -233,7 +231,6 @@ public static PropertyHelper[] GetVisibleProperties(
getMethod,
propertyGetterWrapperMethod);
}
#pragma warning restore IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
}
else
{
Expand Down Expand Up @@ -287,8 +284,6 @@ public static PropertyHelper[] GetVisibleProperties(
// MakeGenericMethod + value type requires IsDynamicCodeSupported to be true.
if (RuntimeFeature.IsDynamicCodeSupported)
{
// TODO: Remove disable when https://github.com/dotnet/linker/issues/2715 is complete.
#pragma warning disable IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
// Instance methods in the CLR can be turned into static methods where the first parameter
// is open over "target". This parameter is always passed by reference, so we have a code
// path for value types and a code path for reference types.
Expand All @@ -305,7 +300,6 @@ public static PropertyHelper[] GetVisibleProperties(
typeof(Action<object, object?>), propertySetterAsAction);

return (Action<object, object?>)callPropertySetterDelegate;
#pragma warning restore IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
}
else
{
Expand Down

0 comments on commit f8c9806

Please sign in to comment.