diff --git a/docs/tools/illink/data-formats.md b/docs/tools/illink/data-formats.md index 06490e3e3308d9..7756d91728c440 100644 --- a/docs/tools/illink/data-formats.md +++ b/docs/tools/illink/data-formats.md @@ -253,6 +253,21 @@ Entire method body is replaces with `throw` instruction when method is reference ``` +### Throw PlatformNotSupportedException + + +Entire method body is replaces with `throw new PlatformNotSupportedException()` instruction when method is referenced. + +```xml + + + + + + + +``` + ### Remove embedded resources ```xml diff --git a/src/libraries/System.Threading/src/System.Threading.csproj b/src/libraries/System.Threading/src/System.Threading.csproj index e09ac58c61c410..613c3a16dace2a 100644 --- a/src/libraries/System.Threading/src/System.Threading.csproj +++ b/src/libraries/System.Threading/src/System.Threading.csproj @@ -8,6 +8,7 @@ false true $(DefineConstants);FEATURE_WASM_MANAGED_THREADS + <_ExtraTrimmerArgs Condition="'$(TargetsBrowser)' == 'true'">$(_ExtraTrimmerArgs) --target-os browser diff --git a/src/libraries/sfx-finish.proj b/src/libraries/sfx-finish.proj index 742bafb20541d6..4cf2dcee7eedd5 100644 --- a/src/libraries/sfx-finish.proj +++ b/src/libraries/sfx-finish.proj @@ -127,6 +127,7 @@ $(SharedFrameworkILLinkArgs) -b true $(SharedFrameworkILLinkArgs) --link-attributes "@(SharedFrameworkSuppressionsXml, '" --link-attributes "')" + $(SharedFrameworkILLinkArgs) --target-os browser diff --git a/src/tools/illink/src/ILLink.Shared/TypeSystemProxy/WellKnownType.cs b/src/tools/illink/src/ILLink.Shared/TypeSystemProxy/WellKnownType.cs index 9b4d435f9d5731..ab8b19d3d74247 100644 --- a/src/tools/illink/src/ILLink.Shared/TypeSystemProxy/WellKnownType.cs +++ b/src/tools/illink/src/ILLink.Shared/TypeSystemProxy/WellKnownType.cs @@ -19,6 +19,7 @@ public enum WellKnownType System_Object, System_Attribute, System_NotSupportedException, + System_PlatformNotSupportedException, System_Runtime_CompilerServices_DisablePrivateReflectionAttribute, System_Void } @@ -37,6 +38,7 @@ public static (string Namespace, string Name) GetNamespaceAndName(this WellKnown WellKnownType.System_Object => ("System", "Object"), WellKnownType.System_Attribute => ("System", "Attribute"), WellKnownType.System_NotSupportedException => ("System", "NotSupportedException"), + WellKnownType.System_PlatformNotSupportedException => ("System", "PlatformNotSupportedException"), WellKnownType.System_Runtime_CompilerServices_DisablePrivateReflectionAttribute => ("System.Runtime.CompilerServices", "DisablePrivateReflectionAttribute"), WellKnownType.System_Void => ("System", "Void"), _ => throw new System.ArgumentException(type.ToString()) @@ -57,6 +59,7 @@ public static (string Namespace, string Name) GetNamespaceAndName(this WellKnown "Attribute" => WellKnownType.System_Attribute, "Object" => WellKnownType.System_Object, "NotSupportedException" => WellKnownType.System_NotSupportedException, + "PlatformNotSupportedException" => WellKnownType.System_PlatformNotSupportedException, "Void" => WellKnownType.System_Void, _ => null }, diff --git a/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets b/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets index 16198390f88f7b..7c7bb02e9660ec 100644 --- a/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets +++ b/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets @@ -90,6 +90,10 @@ Copyright (c) .NET Foundation. All rights reserved. $(NoWarn);IL2121 + + <_ExtraTrimmerArgs>$(_ExtraTrimmerArgs) --target-os browser + +