From f7cf85e263679d1b20276a6403812d5057a70e80 Mon Sep 17 00:00:00 2001 From: Sebastien Lebreton Date: Sun, 19 Jul 2026 18:13:17 +0200 Subject: [PATCH] Remove obsolete lifetime annotation fields ScopedKind is now the authoritative lifetime representation, so retaining the preview-era boolean fields would duplicate state. Keep the current ScopedRef compatibility property and group the new metadata attributes with the other C# 11 attributes. Assisted-by: Copilot:gpt-5.6-sol:GitHub Copilot CLI Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 86d2918e-5a24-48b4-9a86-41d331ec3720 --- .../TypeSystem/IParameter.cs | 25 +------------------ .../Implementation/KnownAttributes.cs | 13 ++++------ 2 files changed, 6 insertions(+), 32 deletions(-) diff --git a/ICSharpCode.Decompiler/TypeSystem/IParameter.cs b/ICSharpCode.Decompiler/TypeSystem/IParameter.cs index 441da2e03..7937affc4 100644 --- a/ICSharpCode.Decompiler/TypeSystem/IParameter.cs +++ b/ICSharpCode.Decompiler/TypeSystem/IParameter.cs @@ -18,7 +18,6 @@ #nullable enable -using System; using System.Collections.Generic; using System.Runtime.CompilerServices; @@ -52,23 +51,7 @@ namespace ICSharpCode.Decompiler.TypeSystem /// Gets or sets the scope explicitly encoded by ScopedRefAttribute. /// Implicit and redundant scopedness is excluded. /// - public ScopedKind DeclaredScope { - get { -#pragma warning disable 618 - if (ValueScoped) - return ScopedKind.ScopedValue; - if (RefScoped) - return ScopedKind.ScopedRef; -#pragma warning restore 618 - return ScopedKind.None; - } - set { -#pragma warning disable 618 - RefScoped = value != ScopedKind.None; - ValueScoped = value == ScopedKind.ScopedValue; -#pragma warning restore 618 - } - } + public ScopedKind DeclaredScope { get; set; } /// /// C# 11 scoped annotation: "scoped ref" (ScopedRefAttribute) @@ -78,12 +61,6 @@ namespace ICSharpCode.Decompiler.TypeSystem set { DeclaredScope = value ? ScopedKind.ScopedRef : ScopedKind.None; } } - [Obsolete("Use ScopedRef property instead of directly accessing this field")] - public bool RefScoped; - - [Obsolete("C# 11 preview: \"ref scoped\" no longer supported")] - public bool ValueScoped; - /// /// Gets or sets whether UnscopedRefAttribute is present. /// diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/KnownAttributes.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/KnownAttributes.cs index d34609633..5f3184493 100644 --- a/ICSharpCode.Decompiler/TypeSystem/Implementation/KnownAttributes.cs +++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/KnownAttributes.cs @@ -114,21 +114,19 @@ namespace ICSharpCode.Decompiler.TypeSystem // C# 11 attributes: Required, + UnscopedRef, + RefSafetyRules, // C# 12 attributes: InlineArray, // C# 14 attributes: ExtensionMarker, - - // Lifetime attributes: - UnscopedRef, - RefSafetyRules, } public static class KnownAttributes { - internal const int Count = (int)KnownAttribute.RefSafetyRules + 1; + internal const int Count = (int)KnownAttribute.ExtensionMarker + 1; static readonly TopLevelTypeName[] typeNames = new TopLevelTypeName[Count]{ default, @@ -200,13 +198,12 @@ namespace ICSharpCode.Decompiler.TypeSystem new TopLevelTypeName("System.Runtime.InteropServices", "UnmanagedCallersOnlyAttribute"), // C# 11 attributes: new TopLevelTypeName("System.Runtime.CompilerServices", "RequiredMemberAttribute"), + new TopLevelTypeName("System.Diagnostics.CodeAnalysis", "UnscopedRefAttribute"), + new TopLevelTypeName("System.Runtime.CompilerServices", "RefSafetyRulesAttribute"), // C# 12 attributes: new TopLevelTypeName("System.Runtime.CompilerServices", "InlineArrayAttribute"), // C# 14 attributes: new TopLevelTypeName("System.Runtime.CompilerServices", "ExtensionMarkerAttribute"), - // Lifetime attributes: - new TopLevelTypeName("System.Diagnostics.CodeAnalysis", "UnscopedRefAttribute"), - new TopLevelTypeName("System.Runtime.CompilerServices", "RefSafetyRulesAttribute"), }; public static ref readonly TopLevelTypeName GetTypeName(this KnownAttribute attr)