-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Avoid S.R.I.RuntimeInformation package dependency #85642
Avoid S.R.I.RuntimeInformation package dependency #85642
Conversation
3a524df
to
4238e86
Compare
Tagging subscribers to this area: @dotnet/area-infrastructure-libraries Issue DetailsContributes to #85641 System.Runtime.InteropServices.RuntimeInformation/4.3.0 is being referenced in a few .NET Framework builds. The reference to that package is undesirable as it brings in the entire netstandard1.x dependency graph. Instead, use System.Environment.OSVersion which returns "Microsoft cc @dotnet/area-dependencymodel @dotnet/area-extensions-hosting @dotnet/area-extensions-logging
|
a313a67
to
747bd18
Compare
Contributes to dotnet#85641 System.Runtime.InteropServices.RuntimeInformation/4.3.0 is being referenced in a few .NET Framework builds. The reference to that package is undesirable as it brings in the entire netstandard1.x dependency graph. Instead, use System.Environment.OSVersion which returns "Microsoft Windows NT" on .NET Framework, Mono and .NETCoreApp runtimes.
747bd18
to
1754a36
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -106,11 +106,15 @@ public static IServiceCollection AddWindowsService(this IServiceCollection servi | |||
|
|||
private static void AddWindowsServiceLifetime(IServiceCollection services, Action<WindowsServiceLifetimeOptions> configure) | |||
{ | |||
#if !NETFRAMEWORK | |||
Debug.Assert(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These don't seem all that valuable. According to 04442bf#r759693314 it's to workaround an issue in the analyzer. I wonder if that issue still exists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if that issue still exists?
Probably would still warn as I don't see any annotation or guard. Isn't it windows only? Then we might want to add [SupportedOSPlatformGuard("windows")]
attribute to this type to suppress the warnings here and propagate the warning to the callers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add one minor comment. LGTM otherwise.
#if !NETFRAMEWORK | ||
RuntimeInformation.IsOSPlatform(OSPlatform.Windows); | ||
#else | ||
Environment.OSVersion.StartsWith("Microsoft Windows NT"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should always return true anyway when running with NETFX. why we bother getting the OS version anyway?
Contributes to #85641
System.Runtime.InteropServices.RuntimeInformation/4.3.0 is being referenced in a few .NET Framework builds. The reference to that package is undesirable as it brings in the entire netstandard1.x dependency graph.
Instead, use System.Environment.OSVersion which returns "Microsoft
Windows NT" on .NET Framework, Mono and .NETCoreApp runtimes.
cc @dotnet/area-dependencymodel @dotnet/area-extensions-hosting @dotnet/area-extensions-logging