diff options
author | Jan Kotas <jkotas@microsoft.com> | 2019-07-03 08:59:25 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-03 08:59:25 -0700 |
commit | 60f1e6265bd1039f023a82e0643b524d6aaf7845 (patch) | |
tree | 3d9eb61e3e14106c9cf25fcd966d4432f368aa52 /src/System.Private.CoreLib | |
parent | 93404779a95a776e17326d1014dd7d34e240e3f0 (diff) | |
download | coreclr-60f1e6265bd1039f023a82e0643b524d6aaf7845.tar.gz coreclr-60f1e6265bd1039f023a82e0643b524d6aaf7845.tar.bz2 coreclr-60f1e6265bd1039f023a82e0643b524d6aaf7845.zip |
Cleanup IL linker heuristic usage (#25547)
Prep-work for using mainstream IL linker
Diffstat (limited to 'src/System.Private.CoreLib')
7 files changed, 20 insertions, 52 deletions
diff --git a/src/System.Private.CoreLib/ILLink.targets b/src/System.Private.CoreLib/ILLink.targets index e5ede35f04..7fa64fe76f 100644 --- a/src/System.Private.CoreLib/ILLink.targets +++ b/src/System.Private.CoreLib/ILLink.targets @@ -62,8 +62,6 @@ <ILLinkArgs>$(ILLinkArgs) -v true</ILLinkArgs> <!-- don't remove the embedded root xml resource since ILLink may run again on the assembly --> <ILLinkArgs>$(ILLinkArgs) --strip-resources false</ILLinkArgs> - <!-- reflection heuristics to apply --> - <ILLinkArgs>$(ILLinkArgs) -h LdtokenTypeMethods,InstanceConstructors</ILLinkArgs> </PropertyGroup> <MakeDir Directories="$(ILLinkTrimInputPath)" /> diff --git a/src/System.Private.CoreLib/ILLinkTrim.xml b/src/System.Private.CoreLib/ILLinkTrim.xml index d88232b42b..5fbd0a9e9d 100644 --- a/src/System.Private.CoreLib/ILLinkTrim.xml +++ b/src/System.Private.CoreLib/ILLinkTrim.xml @@ -45,16 +45,32 @@ <!-- Methods is used by VS Tasks Window. --> <method name="GetActiveTaskFromId" /> </type> + <type fullname="System.Collections.Generic.GenericArraySortHelper`1"> + <!-- Instantiated via reflection --> + <method name=".ctor" /> + </type> + <type fullname="System.Collections.Generic.GenericArraySortHelper`2"> + <!-- Instantiated via reflection --> + <method name=".ctor" /> + </type> <!-- Accessed via private reflection by tracing controller. --> <type fullname="System.Diagnostics.Tracing.EventPipe*" /> <!-- Accessed via private reflection and by native code. --> <type fullname="System.Diagnostics.Tracing.RuntimeEventSource" /> + <type fullname="System.Diagnostics.Tracing.NativeRuntimeEventSource" /> <!-- Accessed via reflection in TraceLogging-style EventSource events. --> <type fullname="*f__AnonymousType*" /> + <type fullname="System.Diagnostics.Tracing.PropertyValue/ReferenceTypeHelper`1"> + <!-- Instantiated via reflection --> + <method name=".ctor" /> + </type> <!-- Accessed via native code. --> <type fullname="System.Runtime.InteropServices.ComTypes.IEnumerable" /> <type fullname="System.Runtime.InteropServices.CustomMarshalers.*" /> <!-- Accessed by the WinRT Host --> <type fullname="Internal.Runtime.InteropServices.WindowsRuntime.ActivationFactoryLoader" /> + <!-- Workaround for https://github.com/mono/linker/issues/378 --> + <type fullname="System.Runtime.InteropServices.IDispatch" /> + <type fullname="Internal.Runtime.InteropServices.IClassFactory2" /> </assembly> </linker> diff --git a/src/System.Private.CoreLib/Resources/Strings.resx b/src/System.Private.CoreLib/Resources/Strings.resx index 653c1d3d05..e8bc95242f 100644 --- a/src/System.Private.CoreLib/Resources/Strings.resx +++ b/src/System.Private.CoreLib/Resources/Strings.resx @@ -3385,9 +3385,6 @@ <data name="Serialization_MissingValues" xml:space="preserve"> <value>The values for this dictionary are missing.</value> </data> - <data name="Serialization_NonSerType" xml:space="preserve"> - <value>Type '{0}' in Assembly '{1}' is not marked as serializable.</value> - </data> <data name="Serialization_NoParameterInfo" xml:space="preserve"> <value>Serialized member does not have a ParameterInfo.</value> </data> diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs index 90edaed662..bf25248d94 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs @@ -3836,18 +3836,6 @@ namespace System.Diagnostics.Tracing return -1; } -#if false // This routine is not needed at all, it was used for unit test debugging. - [Conditional("DEBUG")] - private static void OutputDebugString(string msg) - { -#if !ES_BUILD_PCL - msg = msg.TrimEnd('\r', '\n') + - string.Format(CultureInfo.InvariantCulture, ", Thrd({0})" + Environment.NewLine, Environment.CurrentManagedThreadId); - System.Diagnostics.Debugger.Log(0, null, msg); -#endif - } -#endif - /// <summary> /// Sends an error message to the debugger (outputDebugString), as well as the EventListeners /// It will do this even if the EventSource is not enabled. @@ -3898,11 +3886,6 @@ namespace System.Diagnostics.Tracing private bool ThrowOnEventWriteErrors { get { return (m_config & EventSourceSettings.ThrowOnEventWriteErrors) != 0; } - set - { - if (value) m_config |= EventSourceSettings.ThrowOnEventWriteErrors; - else m_config &= ~EventSourceSettings.ThrowOnEventWriteErrors; - } } private bool SelfDescribingEvents @@ -3913,19 +3896,6 @@ namespace System.Diagnostics.Tracing ((m_config & EventSourceSettings.EtwSelfDescribingEventFormat) != 0)); return (m_config & EventSourceSettings.EtwSelfDescribingEventFormat) != 0; } - set - { - if (!value) - { - m_config |= EventSourceSettings.EtwManifestEventFormat; - m_config &= ~EventSourceSettings.EtwSelfDescribingEventFormat; - } - else - { - m_config |= EventSourceSettings.EtwSelfDescribingEventFormat; - m_config &= ~EventSourceSettings.EtwManifestEventFormat; - } - } } // private instance state diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/FieldMetadata.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/FieldMetadata.cs index 2c50266134..06084f4c92 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/FieldMetadata.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/FieldMetadata.cs @@ -76,7 +76,6 @@ namespace System.Diagnostics.Tracing fixedCount, null) { - return; } /// <summary> @@ -95,7 +94,6 @@ namespace System.Diagnostics.Tracing checked((ushort)(custom == null ? 0 : custom.Length)), custom) { - return; } private FieldMetadata( diff --git a/src/System.Private.CoreLib/shared/System/Runtime/Serialization/SafeSerializationEventArgs.cs b/src/System.Private.CoreLib/shared/System/Runtime/Serialization/SafeSerializationEventArgs.cs index 896b91fca0..ccc518ff96 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/Serialization/SafeSerializationEventArgs.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Serialization/SafeSerializationEventArgs.cs @@ -6,24 +6,13 @@ using System.Collections.Generic; namespace System.Runtime.Serialization { - // SafeSerializationEventArgs are provided to the delegates which do safe serialization. Each delegate - // serializes its own state into an IDeserializationCallback instance which must, itself, be serializable. - // These indivdiual states are then added to the SafeSerializationEventArgs in order to be saved away when - // the original ISerializable type is serialized. + // This type exists for public surface compatibility only. public sealed class SafeSerializationEventArgs : EventArgs { - private readonly List<object> _serializedStates = new List<object>(); - - internal SafeSerializationEventArgs() { } + private SafeSerializationEventArgs() { } public void AddSerializedState(ISafeSerializationData serializedState) { - if (serializedState == null) - throw new ArgumentNullException(nameof(serializedState)); - if (!serializedState.GetType().IsSerializable) - throw new ArgumentException(SR.Format(SR.Serialization_NonSerType, serializedState.GetType(), serializedState.GetType().Assembly.FullName)); - - _serializedStates.Add(serializedState); } public StreamingContext StreamingContext { get; } diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs index 072b3605ee..b63a167897 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs @@ -262,7 +262,7 @@ namespace System.Reflection.Emit ref StackCrawlMark stackMark, AssemblyBuilderAccess access); - private class AssemblyBuilderLock { } + private static readonly object s_assemblyBuilderLock = new object(); internal static AssemblyBuilder InternalDefineDynamicAssembly( AssemblyName name, @@ -270,7 +270,7 @@ namespace System.Reflection.Emit ref StackCrawlMark stackMark, IEnumerable<CustomAttributeBuilder>? unsafeAssemblyAttributes) { - lock (typeof(AssemblyBuilderLock)) + lock (s_assemblyBuilderLock) { // We can only create dynamic assemblies in the current domain return new AssemblyBuilder(name, |