-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Proposed additions to RuntimeInformation #20400
Comments
I was literally this morning typing up a proposal to at least add a strongly typed enum for runtime name. Right now to figure out we are running on desktop, we do string parsing: it should be possible to do something like |
For the Version APIs how do you propose we determine each of them? For example for OSVersion not all OS's are pure number based versions, so should this be a string or a new Version type that supports semantic versioning? For the RuntimeVersion where would we embed this information? Today we don't really have a way to determine what .NET Core you are running on. When running on the shared framework we might be able to figure some of that out but when not I'm not sure where that would come from. Similar for InstalledRuntimeVersions where would we probe for that information?
@danmosemsft FrameworkDescription is intended for logging information. To determine which framework people built against for runtime checks you should be using AppContext.TargetFramework. |
I wouldn't think we would invent anything clever for OSVersion. Return what is readily offered by the system. In the Linux case it happens to look like a number. Could we rely on the contents of /share/Microsoft.NETCore.App or is that too naive? |
It can contain more then just numeric versions see https://www.freedesktop.org/software/systemd/man/os-release.html
That might help for shared applications but doesn't help for standalone at all. |
Yes, I understand that. Just suggesting we return whatever is readily available, eg a string.
That's why the smart folks are here to figure out the options ;-) |
Can I ask you to update the proposal with some scenarios (i.e. coding scenarios) we want folks to be doing with these new APIs? If we plan folks to make runtime decisions based on this version then having it be a string isn't a good way to expose this information because everyone will still have to figure out how to parse it.
There isn't any good way that I'm aware of to do this, that would work across all our .NET Platforms, which is why I'm asking questions. |
For the OSVersion thing, it might not be possible to reliably implement this on Windows (e.g. GetVersionEx will return the version that the program is manifested for and never anything higher - and Windows team is slowly eradicating other undocumented places people use to get Windows version). They really don't want programs to use that to drive decisions. |
And how about the supported in other platforms, like Android, iOS, FreeBSD, etc.? Do we have an idea about what facilities exist there? |
If the intention to use os version is to make runtime decisions for the availability of a feature, etc, then we could have an api like For other purposes like displaying the version, we can just return a string that we get from the OS. How the developer intends to use this string, will be out of scope of the .NET API contract. This API will be similar to |
Priya is capturing the primary use category I was envisioning. Namely, this will simply report environment information as presented by the OS and attempting to account for the usage of the data is essentially impossible. Will add a few scenarios including those which have been raised in other issues to hopefully clarify. |
Note we already have These values are necessary to figure out the Can consumers who need these values just use these existing APIs? |
@weshaggard @terrajobst - we really should rectify the APIs in PlatformAbstractions with RuntimeInformation. The APIs in PlatformAbstractions came from needing this functionality in the CLI, but not having the necessary APIs in the BCL. So the CLI team created these APIs and they made their way into dotnet/core-setup. We (the runtime team) own both corefx and core-setup and the APIs exposed by both repos. So we should have a coherent story here. |
Any managed library (such as msbuild task) that loads native library needs to know RID. This need came up recently in |
Since dotnet/corefx#16629, dotnet/corefx#17452, dotnet/corefx#23197, dotnet/corefx#24522, dotnet/corefx#25530, dotnet/corefx#27417 and dotnet/corefx#28132 are all similar proposals if we think from the perspective of bringing over https://github.com/dotnet/core-setup/tree/fd1dc48fad5bc32258c8c0fc885fbf4b1e32bebd/src/managed/Microsoft.DotNet.PlatformAbstractions to CoreFX that was proposed in https://github.com/dotnet/corefx/issues/28620 by @weshaggard, could the area owner of S.R.I.RuntimeInformation combine these proposals for a more broader API review encompassing various known use-cases? |
@danmosemsft, can we get someone assigned to this? Iike to see a unification proposal that effectively eliminates the need for PlatformAbstractions as a second place to get runtime info. |
I closed couple of related issues as duplicates. I agree with "ghost" (https://github.com/dotnet/corefx/issues/16629#issuecomment-388003268) that we should initially focus on bringing over what public static partial class RuntimeInformation
{
private static string OSName { get; }
private static string OSVersion { get; }
private static string RuntimeIdentifier { get; }
}
I chose OS over OperatingSystem as we already use OS in Thoughts? |
Why is "RuntimeVersions" plural? Can an app be using multiple runtime versions? If so, how? Also, please don't make the users parse the actual version number out of a string like "NETCore.App 1.0.4". It's better than nothing, of course, but it would be great to get a System.Version object here. |
RuntimeVersion is not part of my api suggestion as it's already covered by dotnet/coreclr#22664 and does not need an api review. |
@ViktorHofer - I believe this and dotnet/corefx#31002 are duplicates (or very, very closely related). For sure, your proposal above is an exact duplicate of dotnet/corefx#31002 (except for your proposal has Since dotnet/corefx#31002 already has discussion on that exact API, let's use dotnet/corefx#31002 for that API proposal. If this issue has other proposed APIs, let's use this one for those. If not, I think we could close this issue in favor or dotnet/corefx#31002. |
Sounds good. Duplicate of https://github.com/dotnet/corefx/issues/31002 |
https://github.com/dotnet/corefx/issues/12737
RuntimeInformation
Rational and Usage
It is often desirable and necessary for applications to determine execution environment and runtime information. Existing information provided by
System.Runtime.InteropServices.RuntimeInformation
could be enhanced and expanded with additional API to provide robust information.System.Runtime.InteropServices.RuntimeInformation currently provides surface for some of information though modification to current behavior or addition API may be needed.
Existing API
Proposed additions
Open Questions
Updates
Appendix
/etc/os-release
will have the pertinent information on all systemd-based distros. All distros in our current support set use systemd. Alpine Linux includes/etc/os-release
.Variables can be accessed directly with
( source /etc/os-release && echo "$PRETTY_NAME" )
/cc @richlander , @mellinoe , @Petermarcu , @AlexGhiondea , @weshaggard , @danmosemsft
The text was updated successfully, but these errors were encountered: