Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing RUC from Default and Ambient attributes #100821

Merged
merged 4 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/workflow/trimming/feature-switches.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ configurations but their defaults might vary as any SDK can set the defaults dif
| JsonSerializerIsReflectionEnabledByDefault | System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault | When set to false, disables using reflection as the default contract resolver in System.Text.Json |
| EnableGeneratedComInterfaceComImportInterop | System.Runtime.InteropServices.Marshalling.EnableGeneratedComInterfaceComImportInterop | When set to true, enables casting source-generated COM object wrappers to built-in COM-based COM interfaces. |
| _UseManagedNtlm | System.Net.Security.UseManagedNtlm | When set to true, uses built-in managed implementation of NTLM and SPNEGO algorithm for HTTP, SMTP authentication, and NegotiateAuthentication API instead of system provided GSSAPI implementation. |
| _DesignerHostSupport | System.ComponentModel.Design.IDesignerHost.IsSupported | When set to true, supports creating design components at runtime. |
| _DefaultValueAttributeSupport | System.ComponentModel.DefaultValueAttribute.IsSupported | When set to true, supports creating a DefaultValueAttribute at runtime. |

Any feature-switch which defines property can be set in csproj file or
on the command line as any other MSBuild property. Those without predefined property name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public AmbientValueAttribute(long value) { }
public AmbientValueAttribute(object? value) { }
public AmbientValueAttribute(float value) { }
public AmbientValueAttribute(string? value) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("AmbientValueAttribute usage of TypeConverter is not compatible with trimming.")]
public AmbientValueAttribute([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type type, string value) { }
public object? Value { get { throw null; } }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ public sealed class AmbientValueAttribute : Attribute
/// specified value to the specified type, and using the U.S. English culture as the
/// translation context.
/// </summary>
[RequiresUnreferencedCode(TypeConverter.RequiresUnreferencedCodeMessage)]
[RequiresUnreferencedCode("AmbientValueAttribute usage of TypeConverter is not compatible with trimming.")]
public AmbientValueAttribute([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, string value)
LakshanF marked this conversation as resolved.
Show resolved Hide resolved
{
// The try/catch here is because attributes should never throw exceptions. We would fail to
// load an otherwise normal class.

Debug.Assert(IDesignerHost.IsSupported, "Runtime instantiation of this attribute is not allowed with trimming.");
if (!IDesignerHost.IsSupported)
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ public class DefaultValueAttribute : Attribute
/// class, converting the specified value to the specified type, and using the U.S. English
/// culture as the translation context.
/// </summary>
[RequiresUnreferencedCode("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")]
[RequiresUnreferencedCode("DefaultValueAttribute usage of TypeConverter is not compatible with trimming.")]
sbomer marked this conversation as resolved.
Show resolved Hide resolved
public DefaultValueAttribute(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type,
string? value)
{
// The null check and try/catch here are because attributes should never throw exceptions.
// We would fail to load an otherwise normal class.

Debug.Assert(IsSupported, "Runtime instantiation of this attribute is not allowed with trimming.");
if (!IsSupported)
{
Debug.Assert(!IsSupported, "Runtime instantiation of this attribute is not allowed.");
return;
}

Expand Down Expand Up @@ -69,7 +69,6 @@ public DefaultValueAttribute(
_value = Convert.ChangeType(value, type, CultureInfo.InvariantCulture);
}

[RequiresUnreferencedCode("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")]
// Looking for ad hoc created TypeDescriptor.ConvertFromInvariantString(Type, string)
static bool TryConvertFromInvariantString(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type typeToConvert,
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/System.Runtime/ref/System.Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8047,7 +8047,7 @@ public DefaultValueAttribute(object? value) { }
public DefaultValueAttribute(sbyte value) { }
public DefaultValueAttribute(float value) { }
public DefaultValueAttribute(string? value) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("DefaultValueAttribute usage of TypeConverter is not compatible with trimming.")]
public DefaultValueAttribute([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type type, string? value) { }
[System.CLSCompliantAttribute(false)]
public DefaultValueAttribute(ushort value) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ Copyright (c) .NET Foundation. All rights reserved.
<_UseManagedNtlm Condition="'$(_UseManagedNtlm)' == '' and $(RuntimeIdentifier.StartsWith('linux-bionic'))">true</_UseManagedNtlm>
<!-- Trim managed NTLM on Linux when it's not explicitly requested -->
<_UseManagedNtlm Condition="'$(_UseManagedNtlm)' == '' and $(RuntimeIdentifier.StartsWith('linux'))">false</_UseManagedNtlm>
<_DesignerHostSupport Condition="'$(_DesignerHostSupport)' == ''">false</_DesignerHostSupport>
<_DefaultValueAttributeSupport Condition="'$(_DefaultValueAttributeSupport)' == ''">false</_DefaultValueAttributeSupport>
</PropertyGroup>


Expand Down