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

Don't reference the netstandard shim inside the shared framework #53023

Merged
merged 28 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
84a7872
Don't reference ns.dll inside shared framework
ViktorHofer May 20, 2021
0d414d3
Add netcoreapp2.0 config to SystemEvents
ViktorHofer May 20, 2021
35497b1
Reference netstandard shim in OOBs that require it
ViktorHofer May 20, 2021
15f7a63
Add fallback folder for NetCoreAppCurrent for ApiCompat
ViktorHofer May 20, 2021
a245863
Fix unix configurations
ViktorHofer May 21, 2021
494691d
Fix NullableAttribute ifdefs and trim using
ViktorHofer May 21, 2021
7559971
More fixes
ViktorHofer May 21, 2021
86f2e60
Add additional .NETCoreApp configurations to avoid NS shim
ViktorHofer May 25, 2021
b1b8c5e
Rebase errors fixed
ViktorHofer May 28, 2021
7526e04
Remove unnecessary netcoreapp3.1 configs
ViktorHofer May 31, 2021
5e963d9
Add one more config
ViktorHofer May 31, 2021
774f5ae
Undo ExcludeNetCoreAppCurrent changes
ViktorHofer May 31, 2021
2c3d9f0
Update Microsoft.NETCore.Platforms.csproj
ViktorHofer May 31, 2021
f8fa9c7
Disable failing CodeDom tests
ViktorHofer Jun 1, 2021
fa2d97d
Merge branch 'main' into DefineNetStandardRef
ViktorHofer Jun 8, 2021
577c0f7
Update RequiresUnreferencedCodeAttribute.cs
ViktorHofer Jun 9, 2021
4db5ecd
Update Microsoft.Extensions.Primitives.csproj
ViktorHofer Jun 9, 2021
f5123ff
Update System.Diagnostics.DiagnosticSource.csproj
ViktorHofer Jun 9, 2021
19dd369
Merge remote-tracking branch 'upstream/main' into DefineNetStandardRef
ViktorHofer Jun 9, 2021
1b9c2db
Disable failing tests
ViktorHofer Jun 9, 2021
f6175b8
Apply suggestions from code review
ViktorHofer Jun 10, 2021
a65671c
Update VBCodeGenerationTests.cs
ViktorHofer Jun 10, 2021
459305d
Update ConfigurationSectionTest.cs
ViktorHofer Jun 10, 2021
01a9ab2
Update CodeTypeReference.cs
ViktorHofer Jun 10, 2021
2da8671
Update Microsoft.Extensions.Logging.Console.csproj
ViktorHofer Jun 10, 2021
f461ee8
Update disableVerifyClosure.targets
ViktorHofer Jun 10, 2021
3855df9
Update disableVerifyClosure.targets
ViktorHofer Jun 10, 2021
120d839
PR feedback
ViktorHofer Jun 10, 2021
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
7 changes: 0 additions & 7 deletions eng/references.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
<_FindDependencies>false</_FindDependencies>
</PropertyGroup>

<!-- netstandard is a default reference whenever building an implementation assembly for .NETCoreApp. -->
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and
'$(IsSourceProject)' == 'true'">
<Reference Include="netstandard"
Private="false" />
</ItemGroup>

<!-- If a CoreLib ProjectReference is present, make all P2P assets non transitive. -->
<ItemGroup Condition="'@(ProjectReference)' != '' and
@(ProjectReference->AnyHaveMetadataValue('Identity', '$(CoreLibProject)'))">
Expand Down
2 changes: 2 additions & 0 deletions eng/resolveContract.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<!-- Use implementation referencepath if no contract dependency path is set.
This item transform is executed at the time this property is evaluated in the API Compat targets. -->
<ContractDependencyPaths Condition="'$(ContractDependencyPaths)' == ''">@(ReferencePath->'%(RelativeDir)'->Distinct())</ContractDependencyPaths>
<!-- Fall back to the targeting pack dir for NetCoreAppCurrent to avoid passing through dependencies from ref to src. -->
<ContractDependencyPaths Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', '$(NetCoreAppCurrent)'))">$(ContractDependencyPaths);$(MicrosoftNetCoreAppRefPackRefDir)</ContractDependencyPaths>
</PropertyGroup>

<PropertyGroup Condition="'$(IsSourceProject)' == 'true'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal static partial class Crypt32
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool CryptProtectData(
[In] ref DATA_BLOB pDataIn,
[In] string szDataDescr,
[In] string? szDataDescr,
[In] ref DATA_BLOB pOptionalEntropy,
[In] IntPtr pvReserved,
[In] IntPtr pPromptStruct,
Expand Down
2 changes: 2 additions & 0 deletions src/libraries/Common/src/System/CodeDom/CodeObject.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable enable

using System.Collections;
using System.Collections.Specialized;

Expand Down
4 changes: 3 additions & 1 deletion src/libraries/Common/src/System/CodeDom/CodeTypeReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.Diagnostics;
using System.Globalization;

#nullable enable

#if CODEDOM
namespace System.CodeDom
#else
Expand Down Expand Up @@ -73,7 +75,7 @@ public CodeTypeReference(string typeName, CodeTypeReferenceOptions codeTypeRefer
Initialize(typeName, codeTypeReferenceOption);
}

public CodeTypeReference(string typeName)
public CodeTypeReference(string? typeName)
{
Initialize(typeName);
}
Expand Down
2 changes: 2 additions & 0 deletions src/libraries/Common/src/System/Security/IdentityHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable enable

using System.Diagnostics;
using System.IO;
using System.Reflection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public partial class Logger<T> : Microsoft.Extensions.Logging.ILogger, Microsoft
public Logger(Microsoft.Extensions.Logging.ILoggerFactory factory) { }
System.IDisposable Microsoft.Extensions.Logging.ILogger.BeginScope<TState>(TState state) { throw null; }
bool Microsoft.Extensions.Logging.ILogger.IsEnabled(Microsoft.Extensions.Logging.LogLevel logLevel) { throw null; }
void Microsoft.Extensions.Logging.ILogger.Log<TState>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, TState state, System.Exception exception, System.Func<TState, System.Exception, string> formatter) { }
void Microsoft.Extensions.Logging.ILogger.Log<TState>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, TState state, System.Exception? exception, System.Func<TState, System.Exception?, string> formatter) { }
}
public enum LogLevel
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks>$(NetCoreAppCurrent);netstandard2.0;net461</TargetFrameworks>
Copy link
Member

Choose a reason for hiding this comment

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

CC @maryamariyan @eerhardt
You're adding either NETCoreAppCurrent or netcoreapp3.1 configurations to a lot of libraries.

What made you choose one vs another? For those that are NETCoreAppCurrent do you expect to add more configurations with every release?

Copy link
Member Author

@ViktorHofer ViktorHofer Jun 10, 2021

Choose a reason for hiding this comment

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

In this specific case I added the NetCoreAppCurrent tfm to the reference project as it was already present in the source project. My strategy was:

  1. Make sure that the assembly universe matches between the reference and the source assemblies to avoid an unnecessary reference to the netstandard.dll shim. This is a requirement inside the shared framework but is also desirable in OOB projects to avoid the shim altogether.
  2. In cases where multiple .NETCoreApp versions are present in the source project, choose the minimum required .NETCoreApp tfm in the reference project which in most cases is netcoreapp3.1. In some cases that would have resulted in additional internal files being loaded that aren't necessary on > NET 5 which is why I also added a NetCoreAppCurrent configuration.
  3. Add a NetCoreAppCurrent tfm to OOBs which don't target .NETCoreApp but where it's desirable to avoid the netstandard.dll shim. The desire to avoid the netstandard.dll shim is defined by where the library sits in the graph. If it's at the very top and isn't referenced by any other component it's less of a concern. Going forward it would be nice to avoid the netstandard.dll shim altogether but that's TBD and unrelated to this work.

For those that are NETCoreAppCurrent do you expect to add more configurations with every release?

The netcoreapp3.1 tfms will be upgraded to net6.0 and the NetCoreAppCurrent tfms will be replaced by net6.0 + NetCoreAppCurrent when the repository targets .NET 7.

Related but not yet tackled, there's the discussion to add a .NETCoreApp (presumably NetCoreAppCurrent) tfm to every applicable library that already targets .NETStandard to benefit from linker/compiler/analyzer features. I would like to keep that discussion separate from this effort though.

Copy link
Member

Choose a reason for hiding this comment

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

to benefit from linker/compiler/analyzer features

Also to benefit from new APIs as well.

I'm all for targeting the latest TFM in our OOBs all the time. Especially in the OOBs that go inbox in other teams shared frameworks. I like that we have a decent plan so the TFMs don't continually grow and this strategy will be maintainable.

<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Include="Microsoft.Extensions.Logging.Abstractions.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == '$(NetCoreAppCurrent)'">
<ProjectReference Include="$(LibrariesProjectRoot)System.Runtime\ref\System.Runtime.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private object FormatArgument(object? value)
{
var vsb = new ValueStringBuilder(stackalloc char[256]);
bool first = true;
foreach (object e in enumerable)
foreach (object? e in enumerable)
{
if (!first)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netstandard2.0;net461</TargetFrameworks>
<IncludePlatformAttributes>true</IncludePlatformAttributes>
</PropertyGroup>

<ItemGroup>
<Compile Include="Microsoft.Extensions.Logging.Console.cs" />
</ItemGroup>

<ItemGroup>
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\DynamicallyAccessedMembersAttribute.cs" />
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\DynamicallyAccessedMemberTypes.cs" />
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\RequiresUnreferencedCodeAttribute.cs" />
Expand All @@ -17,4 +20,11 @@
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.Logging\ref\Microsoft.Extensions.Logging.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.Options\ref\Microsoft.Extensions.Options.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<Reference Include="netstandard" />
Copy link
Member

Choose a reason for hiding this comment

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

I thought we were trying to avoid netstandard on .NET Core. Doesn't this go against the goal of this PR?

Copy link
Member

Choose a reason for hiding this comment

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

Repeated in other .csprojs.

Copy link
Member Author

@ViktorHofer ViktorHofer Jun 10, 2021

Choose a reason for hiding this comment

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

The PR only targets getting rid of the netstandard reference inside the shared framework and for some OOBs (which are in the middle of the graph) for NetCoreAppCurrent. There are still 50 libraries that don't have a .NETCoreApp configuration and all of those target .NETStandard. For referencing those we need the netstandard.dll shim as that's the piece that makes referencing a .NETStandard lib from .NETCoreApp work.

My master plan is that still during the .NET 6 timeframe we add a NetCoreAppCurrent configuration to every "applicable" library and with that avoid the necessity of the shim for NetCoreAppCurrent inside our build entirely.

When we then version the repository to .NET 7, we will have a net6.0 and a .net7.0 configuration in all our "applicable" packages and by that then be able to remove the netstandard.dll shim for .NETCoreApp entirely.

Getting rid of the netstandard.dll shim for netcoreapp3.1 would be unwise at this point as we just need to wait until we version the repo and get to net6.0 if my master plan succeeds ;)

<Reference Include="System.Diagnostics.Tracing" />
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Extensions" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Link="Common\Interop\Windows\Interop.GetStdHandle.cs" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != '$(NetCoreAppCurrent)'">
<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net5.0'))">
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\DynamicallyAccessedMembersAttribute.cs" />
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\DynamicallyAccessedMemberTypes.cs" />
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\RequiresUnreferencedCodeAttribute.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netstandard2.0;net461</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<Compile Include="Microsoft.Extensions.Logging.EventSource.cs" />
Expand All @@ -9,4 +9,9 @@
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.Logging\ref\Microsoft.Extensions.Logging.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<Reference Include="netstandard" />
<Reference Include="System.Diagnostics.Tracing" />
<Reference Include="System.Runtime" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netstandard2.0;net461</TargetFrameworks>
Copy link
Member

Choose a reason for hiding this comment

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

Are we sure dropping netstandard2.1 here is correct? Looks like @maryamariyan added it during getting this project moved over to this repo. 2220437

Copy link
Member Author

Choose a reason for hiding this comment

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

The netstandard2.1 reference isn't needed as netstandard2.0 fully satisfies the contract. It's not entirely clear to me why that configuration was added when bringing over the project but it doesn't serve any purpose, especially now that we are adding a .NETCoreApp configuration.

</PropertyGroup>
<ItemGroup>
<Compile Include="Microsoft.Extensions.Primitives.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or
'$(TargetFramework)' == 'net461'">
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
<!-- PrivateAssets=all is a workaround to issue: https://github.com/NuGet/Home/issues/10617 -->
<PackageReference Include="System.Memory" Version="$(SystemMemoryVersion)" PrivateAssets="all" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<Reference Include="System.Runtime" />
Copy link
Member

Choose a reason for hiding this comment

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

Here's a difference from the two projects before this - targetting netcoreapp3.1, but referencing System.Runtime here, vs netstandard above.

Copy link
Member Author

Choose a reason for hiding this comment

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

This project doesn't reference any .NETStandard projects (via P2P) therefore the shim isn't required.

Copy link
Member

Choose a reason for hiding this comment

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

Do we have this written down? It is going to be near impossible for someone to discern the rules of when to reference what.

Copy link
Member Author

Choose a reason for hiding this comment

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

This was already the case before this change for reference projects. Before this PR the netstandard shim was automatically referenced by any .NETCoreApp source project. Reference always had to add the netstandard reference manually when they were referencing a netstandard project.

I do have a presentation planned (target audience Libraries Team) where I will go over the current state of libraries and their packages. Will make sure that the right documentation is in place by then.

</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks>$(NetCoreAppCurrent);netstandard2.0;net461</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Condition="'$(TargetFramework)' != 'net461'" Include="Microsoft.Win32.Registry.cs" />
<Compile Condition="'$(TargetFramework)' == 'net461'" Include="Microsoft.Win32.Registry.net461.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'net461'">
<ProjectReference Include="..\..\System.Security.AccessControl\ref\System.Security.AccessControl.csproj" />
<ProjectReference Include="..\..\System.Security.Principal.Windows\ref\System.Security.Principal.Windows.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Security.AccessControl\ref\System.Security.AccessControl.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<ProjectReference Include="$(LibrariesProjectRoot)System.Security.Principal.Windows\ref\System.Security.Principal.Windows.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == '$(NetCoreAppCurrent)'">
<ProjectReference Include="$(LibrariesProjectRoot)System.Runtime\ref\System.Runtime.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<IsPartialFacadeAssembly Condition="$(TargetFramework.StartsWith('net4'))">true</IsPartialFacadeAssembly>
<NoWarn Condition="'$(TargetsWindows)' != 'true'">$(NoWarn);CA1823</NoWarn> <!-- Avoid unused fields warnings in Unix build -->
</PropertyGroup>
<ItemGroup Condition="!$(TargetFramework.StartsWith('net4'))">
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true'">
<Compile Include="$(CommonPath)Interop\Windows\Advapi32\Interop.RegistryConstants.cs"
Link="Common\Interop\Windows\Advapi32\Interop.RegistryConstants.cs" />
<Compile Include="$(CoreLibSharedDir)Microsoft\Win32\SafeHandles\SafeRegistryHandle.cs"
Expand All @@ -27,7 +27,7 @@
<Compile Include="System\Security\AccessControl\RegistryRights.cs" />
<Compile Include="System\Security\AccessControl\RegistrySecurity.cs" />
</ItemGroup>
<ItemGroup Condition="!$(TargetFramework.StartsWith('net4')) and '$(TargetsWindows)' == 'true'">
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true' and '$(TargetsWindows)' == 'true'">
<Compile Include="$(CommonPath)Interop\Windows\Interop.Libraries.cs"
Link="Common\Interop\Windows\Interop.Libraries.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Interop.Errors.cs"
Expand Down Expand Up @@ -76,7 +76,7 @@
<ProjectReference Include="$(LibrariesProjectRoot)System.Security.AccessControl\src\System.Security.AccessControl.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Security.Principal.Windows\src\System.Security.Principal.Windows.csproj" />
</ItemGroup>
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', '$(NetCoreAppCurrent)'))">
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<Reference Include="System.Buffers" />
<Reference Include="System.Collections" />
<Reference Include="System.Diagnostics.Debug" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netstandard2.0;net461</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Condition="'$(TargetFramework)' != 'net461'" Include="Microsoft.Win32.SystemEvents.cs" />
<Compile Condition="'$(TargetFramework)' == 'net461'" Include="Microsoft.Win32.SystemEvents.net461.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<Reference Include="System.ComponentModel.Primitives" />
<Reference Include="System.Runtime" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;netcoreapp3.1-windows;netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;netcoreapp3.1-windows;netcoreapp3.1;netstandard2.0;net461</TargetFrameworks>
</PropertyGroup>
<!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
<PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/libraries/System.CodeDom/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ System.CodeDom.CodeObject
System.CodeDom.Compiler.CodeDomProvider
Microsoft.CSharp.CSharpCodeProvider
Microsoft.VisualBasic.VBCodeProvider</PackageDescription>
<IncludePlatformAttributes>true</IncludePlatformAttributes>
<UnsupportedOSPlatforms>browser;ios;tvos;maccatalyst</UnsupportedOSPlatforms>
Copy link
Member Author

Choose a reason for hiding this comment

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

@buyaa-n @joperezr @krwq @jeffhandley can you please double check if this is right? The platform analyzer warned for these OSs when I added the .NETCoreApp configuration to System.CodeDom.

Copy link
Member

Choose a reason for hiding this comment

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

if this assembly only supported on certain platforms better to add a Supported attribute for those. If there is no such known list then it is OK, let's ask mono team review @marek-safar

Copy link
Contributor

Choose a reason for hiding this comment

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

can you please double check if this is right?

I think we don't have to support this on Android either

if this assembly only supported on certain platforms better to add a Supported attribute for those.

I don't know what is supported set as the API is pretty weird and uses Process to launch unknown command line.

There is also a question about general single-file support here and the APIs could be considered as incompatible with singe-file too (/cc @agocke @vitek-karas)

</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions src/libraries/System.CodeDom/ref/System.CodeDom.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks>$(NetCoreAppCurrent);netstandard2.0;net461</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<Compile Condition="'$(TargetFramework)' != 'net461'" Include="System.CodeDom.cs" />
<Compile Condition="'$(TargetFramework)' == 'net461'" Include="System.CodeDom.net461.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'net461'">
<ProjectReference Include="..\..\System.Security.Permissions\ref\System.Security.Permissions.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Security.Permissions\ref\System.Security.Permissions.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,11 @@ protected override void GenerateArrayCreateExpression(CodeArrayCreateExpression
string typeName = GetTypeOutput(e.CreateType);
Output.Write(typeName);

if (typeName.IndexOf('(') == -1) // string.Contains(char) is .NetCore2.1+ specific
#if NETCOREAPP
if (!typeName.Contains('('))
#else
if (typeName.IndexOf('(') == -1)
#endif
{
Output.Write("()");
}
Expand Down
16 changes: 15 additions & 1 deletion src/libraries/System.CodeDom/src/System.CodeDom.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>$(DefineConstants);CODEDOM</DefineConstants>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks>$(NetCoreAppCurrent);netstandard2.0;net461</TargetFrameworks>
<SetIsTrimmable>false</SetIsTrimmable>
</PropertyGroup>
<!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
Expand Down Expand Up @@ -129,4 +129,18 @@
<Compile Include="System\Collections\Specialized\FixedStringLookup.cs" />
<Compile Include="$(CommonPath)System\CSharpHelpers.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<Reference Include="System.Collections" />
<Reference Include="System.Collections.NonGeneric" />
<Reference Include="System.Collections.Specialized" />
<Reference Include="System.ComponentModel.Primitives" />
<Reference Include="System.ComponentModel.TypeConverter" />
<Reference Include="System.Diagnostics.Debug" />
<Reference Include="System.Diagnostics.Process" />
<Reference Include="System.IO.FileSystem" />
<Reference Include="System.Resources.ResourceManager" />
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Extensions" />
<Reference Include="System.Threading" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ public static partial class ImmutableHashSet
public static System.Collections.Immutable.ImmutableHashSet<TSource> ToImmutableHashSet<TSource>(this System.Collections.Immutable.ImmutableHashSet<TSource>.Builder builder) { throw null; }
}

#if !NETSTANDARD2_0 && !NETFRAMEWORK
#if NET5_0_OR_GREATER
public sealed partial class ImmutableHashSet<T> : System.Collections.Generic.ICollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IReadOnlyCollection<T>, System.Collections.Generic.ISet<T>, System.Collections.Generic.IReadOnlySet<T>, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.Immutable.IImmutableSet<T>
#else
public sealed partial class ImmutableHashSet<T> : System.Collections.Generic.ICollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IReadOnlyCollection<T>, System.Collections.Generic.ISet<T>, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.Immutable.IImmutableSet<T>
Expand Down Expand Up @@ -905,7 +905,7 @@ public static partial class ImmutableSortedSet
public static System.Collections.Immutable.ImmutableSortedSet<TSource> ToImmutableSortedSet<TSource>(this System.Collections.Immutable.ImmutableSortedSet<TSource>.Builder builder) { throw null; }
}

#if !NETSTANDARD2_0 && !NETFRAMEWORK
#if NET5_0_OR_GREATER
public sealed partial class ImmutableSortedSet<T> : System.Collections.Generic.ICollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IList<T>, System.Collections.Generic.IReadOnlyCollection<T>, System.Collections.Generic.IReadOnlyList<T>, System.Collections.Generic.ISet<T>, System.Collections.Generic.IReadOnlySet<T>, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.Collections.Immutable.IImmutableSet<T>
#else
public sealed partial class ImmutableSortedSet<T> : System.Collections.Generic.ICollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IList<T>, System.Collections.Generic.IReadOnlyCollection<T>, System.Collections.Generic.IReadOnlyList<T>, System.Collections.Generic.ISet<T>, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.Collections.Immutable.IImmutableSet<T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@
Link="Common\System\Runtime\Versioning\NonVersionableAttribute.cs" />
<None Include="Interfaces.cd" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == '$(NetCoreAppCurrent)'">
<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<Reference Include="System.Collections" />
<Reference Include="System.Diagnostics.Contracts" />
<Reference Include="System.Diagnostics.Debug" />
Expand All @@ -93,15 +96,11 @@
<Reference Include="System.Linq" />
<Reference Include="System.Resources.ResourceManager" />
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.CompilerServices.Unsafe" />
<Reference Include="System.Runtime.Extensions" />
<Reference Include="System.Runtime.InteropServices" />
<Reference Include="System.Threading" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
<PackageReference Include="System.Memory" Version="$(SystemMemoryVersion)" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != '$(NetCoreAppCurrent)'">
<ProjectReference Include="$(LibrariesProjectRoot)System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj" />
</ItemGroup>
</Project>
Loading