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

Upgrade our .NET SDK to 5.0 RC 1 #48404

Merged
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
6 changes: 6 additions & 0 deletions eng/targets/Imports.targets
Original file line number Diff line number Diff line change
Expand Up @@ -404,4 +404,10 @@
</ItemGroup>
</Target>

<!-- Override this to work around https://github.com/dotnet/sdk/issues/13427. The property doesn't
appear to be used for anything other than controlling the warning. -->
<PropertyGroup>
<_MicrosoftWindowsDesktopSdkImported>false</_MicrosoftWindowsDesktopSdkImported>
</PropertyGroup>

</Project>
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"sdk": {
"version": "5.0.100-preview.8.20417.9",
"version": "5.0.100-rc.1.20452.10",
"allowPrerelease": true,
"rollForward": "major"
},
"tools": {
"dotnet": "5.0.100-preview.8.20417.9",
"dotnet": "5.0.100-rc.1.20452.10",
"vs": {
"version": "16.8"
},
Copy link
Member

@Youssef1313 Youssef1313 Oct 7, 2020

Choose a reason for hiding this comment

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

Should the next line for xcopy-msbuild be updated to preview 3 instead of preview 2?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

(I think the answer is no because we only rebuild that xcopy package when we need to...)

Copy link
Member

Choose a reason for hiding this comment

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

We only do it when we need to, but the likelihood is that we'll need to. @jaredpar, is there a new version? If not, can you make one?

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable

#if !NET5_0

namespace System.Runtime.Versioning
{
/// <summary>
/// Base type for all platform-specific API attributes.
/// </summary>
internal abstract class OSPlatformAttribute : Attribute
{
private protected OSPlatformAttribute(string platformName)
{
PlatformName = platformName;
}

public string PlatformName { get; }
}

/// <summary>
/// Records the platform that the project targeted.
/// </summary>
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)]
internal sealed class TargetPlatformAttribute : OSPlatformAttribute
{
public TargetPlatformAttribute(string platformName)
: base(platformName)
{
}
}

/// <summary>
/// Records the operating system (and minimum version) that supports an API. Multiple attributes can be
/// applied to indicate support on multiple operating systems.
/// </summary>
/// <remarks>
/// <para>Callers can apply a <see cref="SupportedOSPlatformAttribute" />
/// or use guards to prevent calls to APIs on unsupported operating systems.</para>
///
/// <para>A given platform should only be specified once.</para>
/// </remarks>
[AttributeUsage(
AttributeTargets.Assembly
| AttributeTargets.Class
| AttributeTargets.Constructor
| AttributeTargets.Enum
| AttributeTargets.Event
| AttributeTargets.Field
| AttributeTargets.Method
| AttributeTargets.Module
| AttributeTargets.Property
| AttributeTargets.Struct,
AllowMultiple = true, Inherited = false)]
internal sealed class SupportedOSPlatformAttribute : OSPlatformAttribute
{
public SupportedOSPlatformAttribute(string platformName)
: base(platformName)
{
}
}

/// <summary>
/// Marks APIs that were removed in a given operating system version.
/// </summary>
/// <remarks>
/// Primarily used by OS bindings to indicate APIs that are only available in
/// earlier versions.
/// </remarks>
[AttributeUsage(
AttributeTargets.Assembly
| AttributeTargets.Class
| AttributeTargets.Constructor
| AttributeTargets.Enum
| AttributeTargets.Event
| AttributeTargets.Field
| AttributeTargets.Method
| AttributeTargets.Module
| AttributeTargets.Property
| AttributeTargets.Struct,
AllowMultiple = true, Inherited = false)]
internal sealed class UnsupportedOSPlatformAttribute : OSPlatformAttribute
{
public UnsupportedOSPlatformAttribute(string platformName)
: base(platformName)
{
}
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -502,12 +502,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
#If DEBUG Then
' Compile time asserts.
Private Const s_delegateRelaxationLevelMask_AssertZero = SmallFieldMask.DelegateRelaxationLevelMask - ConversionKind.DelegateRelaxationLevelMask
Private _delegateRelaxationLevelMask_Assert1(s_delegateRelaxationLevelMask_AssertZero) As Boolean
Private _delegateRelaxationLevelMask_Assert2(-s_delegateRelaxationLevelMask_AssertZero) As Boolean
Private ReadOnly _delegateRelaxationLevelMask_Assert1(s_delegateRelaxationLevelMask_AssertZero) As Boolean
Copy link
Member

Choose a reason for hiding this comment

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

The IDE Analyzer MakeFieldReadOnly is already enabled. Why it didn't catch these?

Copy link
Member

Choose a reason for hiding this comment

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

The updated analyzer catches more cases.

Private ReadOnly _delegateRelaxationLevelMask_Assert2(-s_delegateRelaxationLevelMask_AssertZero) As Boolean

Private Const s_inferenceLevelMask_AssertZero = CByte((SmallFieldMask.InferenceLevelMask >> SmallFieldMask.InferenceLevelShift) <> ((TypeArgumentInference.InferenceLevel.Invalid << 1) - 1))
Private _inferenceLevelMask_Assert1(s_inferenceLevelMask_AssertZero) As Boolean
Private _inferenceLevelMask_Assert2(-s_inferenceLevelMask_AssertZero) As Boolean
Private ReadOnly _inferenceLevelMask_Assert1(s_inferenceLevelMask_AssertZero) As Boolean
Private ReadOnly _inferenceLevelMask_Assert2(-s_inferenceLevelMask_AssertZero) As Boolean
#End If
Public Structure OptionalArgument
Public ReadOnly DefaultValue As BoundExpression
Expand Down
4 changes: 4 additions & 0 deletions src/Interactive/HostProcess/InteractiveHost32.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
<ProjectReference Include="..\Host\Microsoft.CodeAnalysis.InteractiveHost.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\..\Compilers\Core\Portable\InternalUtilities\PlatformAttributes.cs" Link="Utilities\PlatformAttributes.cs" />
</ItemGroup>

<!--
InteractiveHost32 is deployed to the same directory as InteractiveHost64 as it shares the same dependencies.

Expand Down
4 changes: 4 additions & 0 deletions src/Interactive/HostProcess/InteractiveHost64.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
<ProjectReference Include="..\Host\Microsoft.CodeAnalysis.InteractiveHost.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\..\Compilers\Core\Portable\InternalUtilities\PlatformAttributes.cs" Link="Utilities\PlatformAttributes.cs" />
</ItemGroup>

<Target Name="PublishProjectOutputGroup" DependsOnTargets="Publish" Returns="@(_PublishedFiles)">
<ItemGroup>
<!-- Need to include and then update items (https://github.com/microsoft/msbuild/issues/1053) -->
Expand Down
4 changes: 4 additions & 0 deletions src/Interactive/HostProcess/InteractiveHostEntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
Expand All @@ -13,6 +14,7 @@ namespace Microsoft.CodeAnalysis.Interactive
{
internal static class InteractiveHostEntryPoint
{
[SupportedOSPlatform("windows")]
Copy link
Member

Choose a reason for hiding this comment

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

Can this be surrounded by #if NET5_0 instead of having to add the PlatformAttributes.cs file? or this won't work?

Copy link
Member

@sharwell sharwell Oct 7, 2020

Choose a reason for hiding this comment

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

I prefer to localize the directives to PlatformAttributes.cs and have the code itself look uniform and, where possible, modern.

Copy link
Member

Choose a reason for hiding this comment

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

Is there not a constant for these?

Copy link
Member

Choose a reason for hiding this comment

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

I didn't see one. dotnet/runtime seems to use strings.

private static async Task<int> Main(string[] args)
{
FatalError.Handler = FailFast.OnFatalException;
Expand Down Expand Up @@ -51,9 +53,11 @@ private static async Task<int> Main(string[] args)
}
}

[SupportedOSPlatform("windows")]
[DllImport("kernel32", PreserveSig = true)]
internal static extern ErrorMode SetErrorMode(ErrorMode mode);

[SupportedOSPlatform("windows")]
[DllImport("kernel32", PreserveSig = true)]
internal static extern ErrorMode GetErrorMode();

Expand Down