Ensure IsExternalInit is type forwarded on NET builds (#619)

It's included as internal on netstandard/net472, and the C# compiler may bake a reference to that into a consumer. If that consumer is then used with a net8.0+ build, the IsExternalInit needs to be there and forwarded to the real one.

This switches our polyfill files to always be included but the actual contents ifdef'd out on TFMs that already have the contents. That then makes it easier to do specialized ifdef'ing in the future, as this does for IsExternalInit.
This commit is contained in:
Stephen Toub 2025-07-14 10:30:48 -04:00 • committed by GitHub
commit 5f1c74f1ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 64 additions and 17 deletions

View file

@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#if !NET
namespace System.Diagnostics.CodeAnalysis;
/// <summary>
@ -162,3 +163,4 @@ internal enum DynamicallyAccessedMemberTypes
/// </summary>
All = ~None
}
#endif

View file

@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#if !NET
namespace System.Diagnostics.CodeAnalysis;
/// <summary>
@ -48,3 +49,4 @@ internal sealed class DynamicallyAccessedMembersAttribute : Attribute
/// </summary>
public DynamicallyAccessedMemberTypes MemberTypes { get; }
}
#endif

View file

@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#if !NET
namespace System.Diagnostics.CodeAnalysis
{
/// <summary>Specifies that null is allowed as an input even if the corresponding type disallows it.</summary>
@ -137,3 +138,4 @@ namespace System.Diagnostics.CodeAnalysis
public string[] Members { get; }
}
}
#endif

View file

@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#if !NET
namespace System.Diagnostics.CodeAnalysis;
/// <summary>
@ -36,3 +37,4 @@ internal sealed class RequiresDynamicCodeAttribute : Attribute
/// </summary>
public string? Url { get; set; }
}
#endif

View file

@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#if !NET
namespace System.Diagnostics.CodeAnalysis;
/// <summary>
@ -37,3 +38,4 @@ internal sealed class RequiresUnreferencedCodeAttribute : Attribute
/// </summary>
public string? Url { get; set; }
}
#endif

View file

@ -1,5 +1,7 @@
#if !NET
namespace System.Diagnostics.CodeAnalysis
{
[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
internal sealed class SetsRequiredMembersAttribute : Attribute;
}
#endif

View file

@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#if !NET
namespace System.Diagnostics.CodeAnalysis;
/// <summary>Specifies the syntax used in a string.</summary>
@ -65,4 +66,5 @@ internal sealed class StringSyntaxAttribute : Attribute
/// <summary>The syntax identifier for strings containing XML.</summary>
public const string Xml = nameof(Xml);
}
}
#endif

View file

@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#if !NET
namespace System.Diagnostics.CodeAnalysis;
/// <summary>
@ -81,4 +82,5 @@ internal sealed class UnconditionalSuppressMessageAttribute : Attribute
/// Gets or sets the justification for suppressing the code analysis message.
/// </summary>
public string? Justification { get; set; }
}
}
#endif