Skip to content

[API Proposal]: Obsolete attributes under S.R.CompilerServices with no effect #113042

Open
@huoyaoyuan

Description

@huoyaoyuan

Background and motivation

In #40622 and #43247, SuppressIldasmAttribute and DisablePrivateReflectionAttribute were obsoleted because the runtime and toolchain no longer respects them. There are other attributes no longer respected by coreclr for a long time. PRs like #112975 are also removing the runtime definition of them. We may like to obsolete these attributes to provide a clear indication.

The list of attributes are:

  • DefaultDependencyAttribute
  • DependencyAttribute
  • CompilationRelaxationsAttribute still emitted by roslyn
  • CompilerGlobalScopeAttribute still used by VS debugger
  • StringFreezingAttribute
  • LoaderOptimizationAttribute

API Proposal

namespace System.Runtime.CompilerServices;
{
+   [Obsolete("LoadHint has no effect on .NET 5+", Id = ???1)]
    public partial class DefaultDependencyAttribute {}

+   [Obsolete("LoadHint has no effect on .NET 5+", Id = ???1)]
    public partial class DependencyAttribute {}

+   [Obsolete("LoadHint has no effect on .NET 5+", Id = ???1)]
    public enum LoadHint {}

+   [Obsolete("StringFreezingAttribute has no effect on .NET 5+", Id = ???2)]
    public partial class StringFreezingAttribute{}
}

namespace System
{
+   [Obsolete("LoaderOptimizationAttribute has no effect on .NET 5+", Id = ???3)]
    public partial class LoaderOptimizationAttribute {}
+   [Obsolete("LoaderOptimizationAttribute has no effect on .NET 5+", Id = ???3)]
    public enum LoaderOptimization {}
}

API Usage

N/A

Alternative Designs

How should the IDs and messages be grouped? Grouping related attributes and enum with a same ID seems reasonable.

Should the message say ".NET 5+" or ".NET 10+"? These attributes have not been respected for a long time.

Risks

We shouldn't want to re-introduce these capabilities in the future.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions