Browse Source

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
pull/3887/head
Sebastien Lebreton 2 months ago committed by Daniel Grunwald
parent
commit
f7cf85e263
  1. 25
      ICSharpCode.Decompiler/TypeSystem/IParameter.cs
  2. 13
      ICSharpCode.Decompiler/TypeSystem/Implementation/KnownAttributes.cs

25
ICSharpCode.Decompiler/TypeSystem/IParameter.cs

@ -18,7 +18,6 @@ @@ -18,7 +18,6 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
@ -52,23 +51,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -52,23 +51,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// Gets or sets the scope explicitly encoded by <c>ScopedRefAttribute</c>.
/// Implicit and redundant scopedness is excluded.
/// </summary>
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; }
/// <summary>
/// C# 11 scoped annotation: "scoped ref" (ScopedRefAttribute)
@ -78,12 +61,6 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -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;
/// <summary>
/// Gets or sets whether <c>UnscopedRefAttribute</c> is present.
/// </summary>

13
ICSharpCode.Decompiler/TypeSystem/Implementation/KnownAttributes.cs

@ -114,21 +114,19 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -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 @@ -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)

Loading…
Cancel
Save