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 references to PlatformAbstractions. #11076

Merged
merged 5 commits into from
Apr 17, 2020

Conversation

eerhardt
Copy link
Member

This will allow us to remove the PlatformAbstractions library from dotnet/runtime.

Contributes to dotnet/runtime#3470

@eerhardt eerhardt requested review from dsplaisted and wli3 March 31, 2020 21:20
@eerhardt eerhardt force-pushed the RemovePlatformAbstractions branch from 0634353 to 5304180 Compare April 6, 2020 17:24
@eerhardt
Copy link
Member Author

eerhardt commented Apr 9, 2020

@dsplaisted @wli3 - thoughts on this?

@dsplaisted
Copy link
Member

@eerhardt Is the RuntimeEnvironment class here a bunch of code copied from the PlatformAbstractions library? Is there a way to avoid adding it here?

@eerhardt
Copy link
Member Author

eerhardt commented Apr 9, 2020

Is the RuntimeEnvironment class here a bunch of code copied from the PlatformAbstractions library?

You can think of it as "moved" code from the PlatformAbstractions library. The main things that dotnet/sdk uses from PlatformAbstractions that we don't have APIs for in .NET 5 are:

  1. OperatingSystemPlatform
  2. OperatingSystemVersion
  3. OperatingSystem

You can see the discussion about these APIs at dotnet/runtime#26780.

Is there a way to avoid adding it here?

The only way of avoiding it that I can think of is to change the callsites in dotnet/sdk to no longer use the above 3 APIs.

As discussed in dotnet/runtime#26780 (comment), dotnet/sdk uses these APIs for logging/telemetry purposes, ex. dotnet --info. However, the dotnet/runtime team doesn't think these APIs are generally useful to developers and actually causes developers to use bad habits by checking if you are running on a specific version of an OS. Thus, the APIs were not approved.

Since dotnet/runtime doesn't want to expose these as APIs, the only options are:

  1. Put the code here, where it is needed
  2. Don't do it at all

So unless we want to change the telemetry information we are sending and change dotnet --info, moving the code here was my only option.

Another potential option would be to use RuntimeInformation.OSDescription instead, but that would still change the format of the telemetry information and the dotnet --info information.

@dsplaisted
Copy link
Member

@eerhardt How likely is it that this logic will need to be updated moving forward? Who will be responsible for maintaining it?

Also it looks like it still has its own implementation of getting the RuntimeIdentifier, can we remove that code and use the one that's being added to the BCL?

@wli3
Copy link

wli3 commented Apr 14, 2020

I am very concerned about this change considering the left over part - RuntimeEnvironment.cs is still so big.

Also there is mostly no test coverage for the entire file -- and it would be hard to test since it varies and requires testing on different machine config -- and that's why it is bad to be in SDK. SDK repo is not setup to test different combination of OSs. If I need to fix a bug in this code, it will be an edit and pray - and find a regression - and fix and pray again situation.

Some ideas:

  1. Keep RuntimeEnvironment.cs in runtime repo and produce a library out of it, since it can be better tested there.
  2. Add full test coverage to RuntimeEnvironment.cs somehow in SDK
  3. RuntimeEnvironment.cs file will still be owned by runtime and log it by this. Considering the repo merge, we no longer have a hard boundary between team and repos, this is normal now.

@eerhardt
Copy link
Member Author

How likely is it that this logic will need to be updated moving forward?

I can't really predict the future, but in the past 2.5 years, this has been the only substantive change: dotnet/core-setup#4085

Who will be responsible for maintaining it?

I'm fine with me or someone from the libraries/runtime team maintaining it. But I don't see it as different than the current get libc version telemetry code we have today.

Also it looks like it still has its own implementation of getting the RuntimeIdentifier, can we remove that code and use the one that's being added to the BCL?

That implementation is used by the GetCurrentRuntimeInformation task in toolset-tasks.csproj, which builds for both netcoreapp and net472. The new API in the BCL is only in netcoreapp.

I am very concerned about this change considering the left over part - RuntimeEnvironment.cs is still so big.

If we can remove the telemetry and dotnet --info functionality that uses this code, we can remove this left over part. For example, do we really need both OS Name and OS Platform in dotnet --info and telemetry? The advantage of putting this code in dotnet/sdk where it is used is if/when we change the telemetry to no longer need this, we can just delete the code. Where if we have this functionality as an official API, we can never remove it.

It looks like some of the version code in RuntimeEnvironment.cs can be refactored to instead use System.Environment.OSVersion. That will make for less code here.

Also there is mostly no test coverage for the entire file

I can add some tests for the functions. For the most part, there are only 3 main code paths: windows, osx, and linux.

Keep RuntimeEnvironment.cs in runtime repo and produce a library out of it, since it can be better tested there.

This is not a viable solution. It is what we have today and what I'm trying to fix. The PlatformAbstractions library is in a weird "limbo" state, where it hasn't been officially approved, but it is in the same repo as the official BCL APIs.

@eerhardt eerhardt force-pushed the RemovePlatformAbstractions branch from 5304180 to 7f69728 Compare April 14, 2020 20:02
@eerhardt
Copy link
Member Author

@dsplaisted @wli3 - I believe I've addressed your feedback. Please let me know what you think.

@wli3
Copy link

wli3 commented Apr 14, 2020

I don't see it as different than the current get libc version

I actually made the same comment then that code was checked-in. And it is also maintained by runtime team

@eerhardt eerhardt force-pushed the RemovePlatformAbstractions branch from b9881e0 to cf1bcc2 Compare April 15, 2020 14:58
Copy link
Member

@dsplaisted dsplaisted left a comment

Choose a reason for hiding this comment

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

I think I am OK with this. The use of this new code is restricted to telemetry and informational output.

As I commented, I think we can get rid of the duplicate GetRuntimeIdentifier implementation altogether.

src/Cli/Microsoft.DotNet.Cli.Utils/RuntimeEnvironment.cs Outdated Show resolved Hide resolved
@eerhardt eerhardt force-pushed the RemovePlatformAbstractions branch from d02ca6b to e07c170 Compare April 16, 2020 14:16
@eerhardt eerhardt merged commit 873d79d into dotnet:master Apr 17, 2020
@eerhardt eerhardt deleted the RemovePlatformAbstractions branch April 17, 2020 12:28
dsplaisted added a commit to dotnet/installer that referenced this pull request Apr 20, 2020
dotnet-maestro bot added a commit to dotnet/installer that referenced this pull request Apr 21, 2020
* Update dependencies from https://github.com/dotnet/sdk build 20200417.2

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.2
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.2

* Update dependencies from https://github.com/dotnet/sdk build 20200417.3

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.3
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.3

* Update dependencies from https://github.com/dotnet/sdk build 20200417.4

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.4
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.4

* Update dependencies from https://github.com/dotnet/sdk build 20200417.5

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.5
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.5

* Update dependencies from https://github.com/dotnet/sdk build 20200417.6

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.6
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.6

* Update dependencies from https://github.com/dotnet/sdk build 20200417.7

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.7
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.7

* Update dependencies from https://github.com/dotnet/sdk build 20200417.8

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.8
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.8

* Update dependencies from https://github.com/dotnet/sdk build 20200418.1

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20218.1
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20218.1

* Update dependencies from https://github.com/dotnet/sdk build 20200418.2

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20218.2
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20218.2

* Update dependencies from https://github.com/dotnet/sdk build 20200418.3

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20218.3
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20218.3

* Update dependencies from https://github.com/dotnet/sdk build 20200418.4

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20218.4
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20218.4

* Update dependencies from https://github.com/dotnet/sdk build 20200419.1

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20219.1
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20219.1

* Update dependencies from https://github.com/dotnet/sdk build 20200419.2

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20219.2
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20219.2

* Update dependencies from https://github.com/dotnet/sdk build 20200419.3

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20219.3
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20219.3

* Update dependencies from https://github.com/dotnet/sdk build 20200420.1

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.1
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.1

* Update dependencies from https://github.com/dotnet/sdk build 20200420.2

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.2
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.2

* Update dependencies from https://github.com/dotnet/sdk build 20200420.3

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.3
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.3

* Switch to using RuntimeInformation APIs instead of deprecated PlatformAbstractions

See dotnet/sdk#11076

* Update dependencies from https://github.com/dotnet/sdk build 20200420.4

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.4
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.4

* Update dependencies from https://github.com/dotnet/sdk build 20200420.5

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.5
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.5

* Update dependencies from https://github.com/dotnet/sdk build 20200420.7

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.7
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.7

* Update dependencies from https://github.com/dotnet/sdk build 20200420.8

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.8
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.8

* Update dependencies from https://github.com/dotnet/sdk build 20200420.10

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.10
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.10

* Update dependencies from https://github.com/dotnet/sdk build 20200420.12

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.12
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.12

* Update dependencies from https://github.com/dotnet/sdk build 20200420.13

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.13
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.13

* Update dependencies from https://github.com/dotnet/sdk build 20200421.1

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20221.1
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20221.1

* Update dependencies from https://github.com/dotnet/sdk build 20200421.2

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20221.2
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20221.2

* Update dependencies from https://github.com/dotnet/sdk build 20200421.3

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20221.3
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20221.3

* Update dependencies from https://github.com/dotnet/sdk build 20200421.4

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20221.4
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20221.4

* Update dependencies from https://github.com/dotnet/sdk build 20200421.5

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.5.20221.5
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.5.20221.5

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Daniel Plaisted <daplaist@microsoft.com>
Anipik pushed a commit to dotnet/installer that referenced this pull request Apr 23, 2020
Anipik pushed a commit to dotnet/installer that referenced this pull request Apr 23, 2020
* Update dependencies from https://github.com/dotnet/sdk build 20200423.3

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20223.3
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20223.3

* Update dependencies from https://github.com/dotnet/sdk build 20200423.5

- Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20223.5
- Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20223.5

* Switch to using RuntimeInformation APIs instead of deprecated PlatformAbstractions

See dotnet/sdk#11076

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Daniel Plaisted <daplaist@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants