Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Honor new properties on ObsoleteAttribute for .NET 5 #8654

Closed

Description

@cartermp

See corresponding Roslyn issue here: dotnet/roslyn#42119

namespace System
{
    public partial class ObsoleteAttribute : Attribute
    {
        // Existing:
        //
        // public ObsoleteAttribute();
        // public ObsoleteAttribute(string message);
        // public ObsoleteAttribute(string message, bool error);
        // public bool IsError { get; }
        // public string Message { get; }

        // New:
        public string DiagnosticId { get; set; }
        public string UrlFormat { get; set; }
    }
}

Handling of these properties is covered in the spec here: https://github.com/dotnet/designs/blob/master/accepted/2020/better-obsoletion/better-obsoletion.md#api-changes

The code to update is here:

let private CheckILAttributes (g: TcGlobals) isByrefLikeTyconRef cattrs m =

Tagging @terrajobst

Activity

  1. abelbraaksma commented on Mar 4, 2020

    @abelbraaksma
  2. abelbraaksma commented on Mar 4, 2020

    @abelbraaksma
  3. terrajobst commented on Mar 4, 2020

    @terrajobst
  4. added
    Area-Compiler-Checking
    on Apr 21, 2022
  5. self-assigned this
    on Dec 22, 2022
  6. removed their assignment
    on May 4, 2023
  7. self-assigned this
    on Jan 3, 2025
  8. jwosty commented on Jul 25, 2026

    @jwosty
    Contributor

    Unless I'm misunderstanding something, the compiler doesn't seem to surface DiagnosticId as the error number.

    For example, compiling this under .NET 10.0.302:

    module MyModule
    
    open System
    
    [<Obsolete("Don't use this, it's evil", DiagnosticId = "FS999")>]
    let f x = x + 1
    
    let g () = f 42

    Gives this output:

    Restore complete (0.2s)
      ObsoleteTest net10.0 succeeded with 1 warning(s) (1.0s) → bin\Debug\net10.0\ObsoleteTest.dll
        C:\Code\Sandbox\ObsoleteTest\Library.fs(8,12): warning FS0044: This construct is deprecated. Don't use this, it's evil
    
    Build succeeded with 1 warning(s) in 1.5s
    

    Shouldn't that produce FS999 rather than FS0044? @T-Gro

  9. T-Gro commented on Aug 1, 2026

    @T-Gro
    Member

    That would make sense to me.
    It was (safely) exposed as a new property of the compiler service returning structured data, but not used for normal diagnostic output.

    Changing this will also mean it should no longer react to --nowarn:44 and instead to its own nowarn.

  10. jwosty commented on Aug 1, 2026

    @jwosty
    Contributor

    To be fair, that is how it works in C# and how I assumed it was going to work when I tried it out. Just some end user data for you :)

    I would love for there to be a way to #nowarn a particular custom warning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area-Compiler-CheckingFeature Request

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions