Skip to content

Commit

Permalink
Backport #51237 to release/6.0-preview4 (#51672)
Browse files Browse the repository at this point in the history
* Include linker fix from dotnet/linker#1972

This fix is necessary for #51237 to
work properly. Otherwise, the linker may crash when analyzing certain patterns.

* Fix EventSource trimmer warning (#51237)

* eh fix

* test change that inadvertently got checked in earlier

* Suppresses the trimmer warning on TypeAnalysis ctor

* Incorporating FB

* Update src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs

Co-authored-by: Eric Erhardt <[email protected]>

* Update src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs

Co-authored-by: Eric Erhardt <[email protected]>

* Update src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs

Co-authored-by: Eric Erhardt <[email protected]>

* Fix DynamicDependency as per PR feedback

* an earlier change got reverted

* fixed proj file netcore app condition check

* fixed NETCORE_ENGINEERING_TELEMETRY build failures

* fixeing another NETCORE_ENGINEERING_TELEMETRY build failures

* Adding RequiresUnreferencedCode to TypeAnalysis ctor instead of suppressing the warning to get FB, not fully fixed

* PR FB and suppressing warnings for safe calls

* propagated the warning all the way up

* CI build break fix for one file

* excluding NativeRTEventSrc from being build in a project

* Missed couple of supppressions on NativeRTEventSrc

* build break fixes

* Trimmer warning fix related to EventSource manifest creation

* incorporate fb

* fix build break in some configs

* comment feedback

* build break

Co-authored-by: Eric Erhardt <[email protected]>
(cherry picked from commit ddaa1c3)

Co-authored-by: Lakshan Fernando <[email protected]>
  • Loading branch information
agocke and LakshanF authored Apr 22, 2021
1 parent 0446f89 commit 96999bc
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>355eff52bed00e7ca9d4a6d769ddbe2bbadbea47</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="6.0.100-preview.2.21215.2">
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="6.0.100-preview.2.21217.1">
<Uri>https://github.com/mono/linker</Uri>
<Sha>1ed6f39a6e716b42fa5e478dcfd30a59f1c8f25e</Sha>
<Sha>0e2e95e9db92cd41f620f96dda84171cbf34fa6c</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="1.0.0-prerelease.21214.1">
<Uri>https://github.com/dotnet/xharness</Uri>
Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
<!-- Docs -->
<MicrosoftPrivateIntellisenseVersion>5.0.0-preview-20201009.2</MicrosoftPrivateIntellisenseVersion>
<!-- ILLink -->
<MicrosoftNETILLinkTasksVersion>6.0.100-preview.2.21215.2</MicrosoftNETILLinkTasksVersion>
<MicrosoftNETILLinkTasksVersion>6.0.100-preview.2.21217.1</MicrosoftNETILLinkTasksVersion>
<!-- ICU -->
<MicrosoftNETCoreRuntimeICUTransportVersion>6.0.0-preview.4.21216.1</MicrosoftNETCoreRuntimeICUTransportVersion>
<!-- Mono LLVM -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public enum EventOpcode
Send = 9,
Receive = 240,
}
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)]
public partial class EventSource : System.IDisposable
{
protected EventSource() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@
<property name="Scope">member</property>
<property name="Target">M:Internal.Runtime.InteropServices.ComponentActivator.InternalGetFunctionPointer(System.Runtime.Loader.AssemblyLoadContext,System.String,System.String,System.IntPtr)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2072</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Diagnostics.Tracing.EventSource.EnsureDescriptorsInitialized</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2075</argument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ internal sealed class EventSourceAutoGenerateAttribute : Attribute
/// }
/// </code>
/// </remarks>
#if !ES_BUILD_STANDALONE
// The EnsureDescriptorsInitialized() method might need to access EventSource and its derived type
// members and the trimmer ensures that these members are preserved.
[DynamicallyAccessedMembers(ManifestMemberTypes)]
#endif
public partial class EventSource : IDisposable
{

Expand Down Expand Up @@ -2765,7 +2770,16 @@ private void EnsureDescriptorsInitialized()
{
// get the metadata via reflection.
Debug.Assert(m_rawManifest == null);
#if !ES_BUILD_STANDALONE
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
Justification = "Based on the annotation on EventSource class, Trimmer will see from its analysis members " +
"that are marked with RequiresUnreferencedCode and will warn." +
"This method will not access any of these members and is safe to call.")]
byte[]? GetCreateManifestAndDescriptorsViaLocalMethod(string name) => CreateManifestAndDescriptors(this.GetType(), name, this);
m_rawManifest = GetCreateManifestAndDescriptorsViaLocalMethod(Name);
#else
m_rawManifest = CreateManifestAndDescriptors(this.GetType(), Name, this);
#endif
Debug.Assert(m_eventData != null);

// TODO Enforce singleton pattern
Expand Down

0 comments on commit 96999bc

Please sign in to comment.