Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Implement UnixFileMode APIs #69980
Implement UnixFileMode APIs #69980
Changes from 39 commits
11c2422
b182b4d
f143499
5138601
4d6c524
813e24a
7bd2ae3
d67d738
3841bfb
d1e7ea8
f7db626
88828a4
cd4104f
c937c28
a12832c
d294651
3df946a
f3c55bf
91e0891
6e74d98
757c1e5
53539ec
873660e
d9c7789
3dba808
33d3e6f
18e70c9
b2423c6
777b77d
4e93e11
60d24a7
8f8ff2d
97df035
7bfa541
01f6ff3
6e91cf1
4cb6316
7046ea9
e55011d
bc7383b
d1f043d
168bdf5
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
This file was deleted.
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.
Can the
Interop.FChMod.cs
file also be deleted from this .csproj?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've added this to avoid the error for using an API that is not supported on Windows.
The file is only used on Unix, so maybe there is a better way to handle this?
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.
@buyaa-n @ViktorHofer the
File.SetUnixFileMode
method is marked as[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")]
and this particular C# file is compiled only for Unix:runtime/src/libraries/System.Formats.Tar/src/System.Formats.Tar.csproj
Lines 52 to 53 in e55011d
Is it expected that the compiler produces warning?
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.
It is not expected, maybe it is loaded in cross platform build? What is the whole warning message? Message includes the call site info
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 added it by mistake to
TarEntry.Unix.cs
. It is only required forZipFileExtensions.ZipArchiveEntry.Extract.Unix.cs
.And there it makes sense because the file is included in
$(NetCoreAppCurrent)
target.The csproj file has:
runtime/src/libraries/System.IO.Compression.ZipFile/src/System.IO.Compression.ZipFile.csproj
Line 4 in 3282677
and
runtime/src/libraries/System.IO.Compression.ZipFile/src/System.IO.Compression.ZipFile.csproj
Lines 25 to 27 in 3282677
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.
The TFMs on this project seem incorrect to me. It has changed quite a few times in the last year.
So unfortunately, because of these TFM changes, the "Unix" build doesn't get the attribute that says "this isn't Windows", which means the analyzer is handicapped here.
Instead of disabling the warning, I think just adding
Debug.Assert(!OperatingSystem.IsWindows());
at the top of the method would be best for now. Long term, I hope we can settle on a manageable TFM plan.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.
@eerhardt can you please elaborate on why you think that the current strategy of choosing target frameworks isn't manageable? cc @ericstj
Some libraries intentionally define a TargetPlatform agnostic target framework which serves as the default configuration to reduce the number of inner builds in the build graph. Such a TargetPlatform agnostic target framework is either truly platform agnostic or it targets a specific platform that is believed to be a good default (in most / all cases Unix).
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.
The SDK unconditionally adds supported platforms and one of those is Windows. The SDK itself doesn't make it possible to only target Windows, macOS or Linux via a target platform, but we in dotnet/runtime allow that via the Microsoft.DotNet.TargetFramework.Sdk.
Because of that, we would need to remove these unconditionally set
SupportedPlatform
items and instead add them conditionally similar to how it is done for Browser.Here you can see that the
SupportedPlatform
metadata is added for Browser when the platform is Browser, or when it's agnostic and the library doesn't have a Browser specific implementation.I think we would want the same for Unix and for any other platform.
EDIT:
Please see ViktorHofer#2 (my fork, just to get feedback). That logic calculates the SupportedPlatforms items correctly based on the RID graph. This implementation is completely static but solves the noted issues.
To make this dynamic, an msbuild task in the TargetFramework.Sdk would be required that takes the build rid graph (OSGroups.json), TargetFrameworks, TargetFramework and TargetPlatformIdentifier as an input and outputs the SupportedPlatform item to be added.
cc @buyaa-n @jeffhandley
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.
SDK supported platforms cause warnings only for cross platform targets, has no effect targeted builds. I might missing something but still do not understand why we could not use Linux or Unix targets for the above mentioned build and keep the $(NetCoreAppCurrent) only for real cross platform targets.
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.
Moved the discussion into #71251.
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.
Can the Interop file be removed from this .csproj?