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

Remove netframework assets older than net461 from builds and packaging #53319

Merged
merged 1 commit into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
#if NET46
using System.Security;
#endif

#pragma warning disable CA1823 // not all IDs are used by all partial providers

Expand All @@ -40,9 +37,6 @@ namespace System.Net
// method that takes an object and optionally provides a string representation of it, in case a particular library wants to customize further.

/// <summary>Provides logging facilities for System.Net libraries.</summary>
#if NET46
[SecuritySafeCritical]
#endif
internal sealed partial class NetEventSource : EventSource
{
/// <summary>The single event source instance to use for all logging.</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
#if NET46
using System.Security;
#endif

#pragma warning disable CA1823 // not all IDs are used by all partial providers

Expand All @@ -39,9 +36,6 @@ namespace System.Net
// method that takes an object and optionally provides a string representation of it, in case a particular library wants to customize further.

/// <summary>Provides logging facilities for System.Net libraries.</summary>
#if NET46
[SecuritySafeCritical]
#endif
internal sealed partial class NetEventSource : EventSource
{
#if !ES_BUILD_STANDALONE
Expand Down
9 changes: 1 addition & 8 deletions src/libraries/Common/src/System/SR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,13 @@ namespace System
{
internal static partial class SR
{
#if !NET45 // AppContext is not supported on < .NET Framework 4.5
private static readonly bool s_usingResourceKeys = AppContext.TryGetSwitch("System.Resources.UseSystemResourceKeys", out bool usingResourceKeys) ? usingResourceKeys : false;
#endif

// This method is used to decide if we need to append the exception message parameters to the message when calling SR.Format.
// by default it returns the value of System.Resources.UseSystemResourceKeys AppContext switch or false if not specified.
// Native code generators can replace the value this returns based on user input at the time of native code generation.
// The Linker is also capable of replacing the value of this method when the application is being trimmed.
private static bool UsingResourceKeys() =>
#if !NET45 // AppContext is not supported on < .NET Framework 4.5
s_usingResourceKeys;
#else
false;
#endif
private static bool UsingResourceKeys() => s_usingResourceKeys;

internal static string GetResourceString(string resourceKey)
{
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<PropertyGroup>
<!-- Build all .NET Framework configurations when net48 is passed in. This is for convenience. -->
<AdditionalBuildTargetFrameworks Condition="'$(BuildTargetFramework)' == 'net48'">net45;net451;net452;net46;net461;net462;net47;net471;net472</AdditionalBuildTargetFrameworks>
<AdditionalBuildTargetFrameworks Condition="'$(BuildTargetFramework)' == 'net48'">net461;net462;net47;net471;net472</AdditionalBuildTargetFrameworks>
<AdditionalBuildTargetFrameworks Condition="'$(DotNetBuildFromSource)' == 'true' and '$(BuildAllProjects)' == 'true'">$(AdditionalBuildTargetFrameworks);netstandard2.0</AdditionalBuildTargetFrameworks>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<ProjectReference Include="..\ref\System.ComponentModel.Composition.Registration.csproj">
<SupportedFramework>netcoreapp3.0;$(AllXamarinFrameworks)</SupportedFramework>
</ProjectReference>
<SupportedFramework Include="net45" Version="4.0.0.0" />
<SupportedFramework Include="net461" Version="4.0.0.0" />
<ProjectReference Include="..\src\System.ComponentModel.Composition.Registration.csproj" />
<InboxOnTargetFramework Include="net45">
<InboxOnTargetFramework Include="net461">
<AsFrameworkReference>true</AsFrameworkReference>
</InboxOnTargetFramework>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" />
<ItemGroup>
<ProjectReference Include="..\ref\System.ComponentModel.Composition.csproj">
<SupportedFramework>uap10.0.16299;netcoreapp2.0;net45;$(AllXamarinFrameworks)</SupportedFramework>
<SupportedFramework>uap10.0.16299;netcoreapp2.0;net461;$(AllXamarinFrameworks)</SupportedFramework>
</ProjectReference>
<ProjectReference Include="..\src\System.ComponentModel.Composition.csproj" />
<InboxOnTargetFramework Include="net45">
<InboxOnTargetFramework Include="net461">
<AsFrameworkReference>true</AsFrameworkReference>
</InboxOnTargetFramework>
<InboxOnTargetFramework Include="uap10.0.16299" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" />
<ItemGroup>
<ProjectReference Include="..\src\System.Diagnostics.DiagnosticSource.csproj">
<SupportedFramework>net45;netcoreapp2.0;uap10.0.16299;$(AllXamarinFrameworks)</SupportedFramework>
<SupportedFramework>net461;netcoreapp2.0;uap10.0.16299;$(AllXamarinFrameworks)</SupportedFramework>
</ProjectReference>

<!-- Since UAP and .NETCoreApp are package based we still want to enable
Expand All @@ -15,7 +15,7 @@
</ValidatePackageSuppression>

<!-- Exclude TFMs that aren't supported by the package anymore from validation. -->
<ExcludeHarvestedSupportedFramework Include="netcoreapp1.0;netcoreapp1.1;netcore45;netcore451;netcore50;uap10.0;wp8;wpa81" />
<ExcludeHarvestedSupportedFramework Include="netcoreapp1.0;netcoreapp1.1;netcore45;netcore451;netcore50;uap10.0;wp8;wpa81;net45;net451;net46" />
</ItemGroup>
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<CLSCompliant>false</CLSCompliant>
<Nullable>enable</Nullable>
</PropertyGroup>
<!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
<PropertyGroup>
<DefineConstants Condition="'$(TargetFramework)' == 'net45'">$(DefineConstants);ALLOW_PARTIALLY_TRUSTED_CALLERS</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)' == 'net461'">$(DefineConstants);ALLOW_PARTIALLY_TRUSTED_CALLERS</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Compile Include="System.Diagnostics.DiagnosticSource.cs" />
Expand All @@ -16,7 +16,7 @@
<ItemGroup>
<PackageReference Include="System.Memory" Version="$(SystemMemoryVersion)" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<Reference Include="System.Runtime" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
<CLSCompliant>false</CLSCompliant>
<NoWarn>$(NoWarn);SA1205</NoWarn>
<Nullable>enable</Nullable>
<TargetFrameworks>$(NetCoreAppCurrent);net5.0;netstandard2.0;net46;net45</TargetFrameworks>
<TargetFrameworks>$(NetCoreAppCurrent);net5.0;netstandard2.0;net461</TargetFrameworks>
<ExcludeCurrentNetCoreAppFromPackage>true</ExcludeCurrentNetCoreAppFromPackage>
</PropertyGroup>
<!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
<PropertyGroup>
<DefineConstants Condition="'$(TargetFramework)' == 'net45'">$(DefineConstants);NO_EVENTSOURCE_COMPLEX_TYPE_SUPPORT;NO_ARRAY_EMPTY_SUPPORT</DefineConstants>
<DefineConstants Condition="$([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)')) == '.NETFramework'">$(DefineConstants);ALLOW_PARTIALLY_TRUSTED_CALLERS;ENABLE_HTTP_HANDLER</DefineConstants>
<DefineConstants Condition="$([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)')) == '.NETCoreApp'">$(DefineConstants);W3C_DEFAULT_ID_FORMAT</DefineConstants>
</PropertyGroup>
Expand Down Expand Up @@ -45,8 +44,8 @@
<Compile Include="System\Diagnostics\Metrics\Histogram.cs" />
<Compile Include="System\Diagnostics\Metrics\Instrument.cs" />
<Compile Include="System\Diagnostics\Metrics\Instrument.common.cs" />
<Compile Include="System\Diagnostics\Metrics\Instrument.netcore.cs" Condition="'$(TargetFramework)' == '$(NetCoreAppCurrent)' Or '$(TargetFramework)' == 'net5.0'" />
<Compile Include="System\Diagnostics\Metrics\Instrument.netfx.cs" Condition="'$(TargetFramework)' != '$(NetCoreAppCurrent)' And '$(TargetFramework)' != 'net5.0'" />
<Compile Include="System\Diagnostics\Metrics\Instrument.netcore.cs" Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'" />
<Compile Include="System\Diagnostics\Metrics\Instrument.netfx.cs" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" />
<Compile Include="System\Diagnostics\Metrics\Measurement.cs" />
<Compile Include="System\Diagnostics\Metrics\Meter.cs" />
<Compile Include="System\Diagnostics\Metrics\MeterListener.cs" />
Expand All @@ -61,12 +60,9 @@
<Link>Common\System\LocalAppContextSwitches.Common.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'net45'">
<ItemGroup>
<Compile Include="System\Diagnostics\Activity.Current.net46.cs" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we rename this file ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes good point. Let's do that another time to not reset the PR.

</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<Compile Include="System\Diagnostics\Activity.Current.net45.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' or
'$(TargetFramework)' == 'netstandard2.0'">
<Compile Include="System\Diagnostics\Activity.DateTime.corefx.cs" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ public void Message(string? Message)
WriteEvent(1, Message);
}

#if !NO_EVENTSOURCE_COMPLEX_TYPE_SUPPORT
/// <summary>
/// Events from DiagnosticSource can be forwarded to EventSource using this event.
/// </summary>
Expand All @@ -232,7 +231,7 @@ private void Event(string SourceName, string EventName, IEnumerable<KeyValuePair
{
WriteEvent(2, SourceName, EventName, Arguments);
}
#endif

/// <summary>
/// This is only used on V4.5 systems that don't have the ability to log KeyValuePairs directly.
/// It will eventually go away, but we should always reserve the ID for this.
Expand All @@ -243,7 +242,6 @@ private void EventJson(string SourceName, string EventName, string ArgmentsJson)
WriteEvent(3, SourceName, EventName, ArgmentsJson);
}

#if !NO_EVENTSOURCE_COMPLEX_TYPE_SUPPORT
/// <summary>
/// Used to mark the beginning of an activity
/// </summary>
Expand Down Expand Up @@ -321,7 +319,6 @@ private void RecursiveActivity1Stop(string SourceName, string EventName, IEnumer
{
WriteEvent(9, SourceName, EventName, Arguments);
}
#endif

/// <summary>
/// Fires when a new DiagnosticSource becomes available.
Expand All @@ -343,11 +340,7 @@ private void NewDiagnosticListener(string SourceName)
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
Justification = "Arguments parameter is trimmer safe")]
#endif
#if NO_EVENTSOURCE_COMPLEX_TYPE_SUPPORT
[Event(11, Keywords = Keywords.Events)]
#else
[Event(11, Keywords = Keywords.Events, ActivityOptions = EventActivityOptions.Recursive)]
#endif
private void ActivityStart(string SourceName, string ActivityName, IEnumerable<KeyValuePair<string, string?>> Arguments) =>
WriteEvent(11, SourceName, ActivityName, Arguments);

Expand All @@ -361,65 +354,16 @@ private void ActivityStart(string SourceName, string ActivityName, IEnumerable<K
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
Justification = "Arguments parameter is trimmer safe")]
#endif
#if NO_EVENTSOURCE_COMPLEX_TYPE_SUPPORT
[Event(12, Keywords = Keywords.Events)]
#else
[Event(12, Keywords = Keywords.Events, ActivityOptions = EventActivityOptions.Recursive)]
#endif
private void ActivityStop(string SourceName, string ActivityName, IEnumerable<KeyValuePair<string, string?>> Arguments) =>
WriteEvent(12, SourceName, ActivityName, Arguments);

#region private

#if NO_EVENTSOURCE_COMPLEX_TYPE_SUPPORT
/// <summary>
/// Converts a keyvalue bag to JSON. Only used on V4.5 EventSources.
/// </summary>
private static string ToJson(IEnumerable<KeyValuePair<string, string>> keyValues)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("{");
bool first = true;
foreach (var keyValue in keyValues)
{
if (!first)
sb.Append(',').AppendLine();
first = false;

sb.Append('"').Append(keyValue.Key).Append("\":\"");

// Write out the value characters, escaping things as needed.
foreach (var c in keyValue.Value)
{
if (char.IsControl(c))
{
if (c == '\n')
sb.Append("\\n");
else if (c == '\r')
sb.Append("\\r");
else
sb.Append("\\u").Append(((int)c).ToString("x").PadLeft(4, '0'));
}
else
{
if (c == '"' || c == '\\')
sb.Append('\\');
sb.Append(c);
}
}
sb.Append('"'); // Close the string.
}
sb.AppendLine().AppendLine("}");
return sb.ToString();
}
#endif

private DiagnosticSourceEventSource()
#if !NO_EVENTSOURCE_COMPLEX_TYPE_SUPPORT
// This constructor uses EventSourceSettings which is only available on V4.6 and above
// Use the EventSourceSettings to turn on support for complex types, if available (v4.6 and above).
: base(EventSourceSettings.EtwSelfDescribingEventFormat)
#endif
{
}

Expand Down Expand Up @@ -672,7 +616,6 @@ public FilterAndTransform(string filterAndPayloadSpec, int startIdx, int endIdx,
Action<string, string, IEnumerable<KeyValuePair<string, string?>>>? writeEvent = null;
if (activityName != null && activityName.Contains("Activity"))
{
#if !NO_EVENTSOURCE_COMPLEX_TYPE_SUPPORT
writeEvent = activityName switch
{
nameof(Activity1Start) => _eventSource.Activity1Start,
Expand All @@ -683,22 +626,14 @@ public FilterAndTransform(string filterAndPayloadSpec, int startIdx, int endIdx,
nameof(RecursiveActivity1Stop) => _eventSource.RecursiveActivity1Stop,
_ => null
};
#endif

if (writeEvent == null)
_eventSource.Message("DiagnosticSource: Could not find Event to log Activity " + activityName);
}

if (writeEvent == null)
{
#if !NO_EVENTSOURCE_COMPLEX_TYPE_SUPPORT
writeEvent = _eventSource.Event;
#else
writeEvent = delegate (string sourceName, string eventName, IEnumerable<KeyValuePair<string, string>> arguments)
{
_eventSource.EventJson(sourceName, eventName, ToJson(arguments));
};
#endif
}

// Set up a subscription that watches for the given Diagnostic Sources and events which will call back
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ namespace System.Diagnostics.Metrics
#endif
public abstract class Instrument
{
#if NO_ARRAY_EMPTY_SUPPORT
internal static KeyValuePair<string, object?>[] EmptyTags { get; } = new KeyValuePair<string, object?>[0];
#else
internal static KeyValuePair<string, object?>[] EmptyTags { get; } = Array.Empty<KeyValuePair<string, object?>>();
#endif // NO_ARRAY_EMPTY_SUPPORT

// The SyncObject is used to synchronize the following operations:
// - Instrument.Publish()
Expand Down
Loading