-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Enumerate files deterministically when compiling *.cs or *.vb #10858
Comments
I'm currently leaning towards won't fix on this. My logic is that, within reason, adding the Fixing this issue would introduce a new observable behavior: partial class ordering. That's not a big difference but is observable. Instead of changing this behavior, I'd instead push on MSBuild / SDK to ensure they give us files in deterministic order as they normally drive our build. Thoughts @gafter? |
I think we should preserve the inputs as given to us and push on other tools to give them to us deterministically. |
I believe the compiler may expand wildcards on input file specifications. If that is so, then the compiler is the only one that has control of the order in which they are enumerated. |
Hmm, I'm not sure if we do or don't do this. Will investigate. If we do manual expansion of *.cs though ourselves then yeah we should probably do it deterministically. |
I'm nearly certain we do wildcard expansion as that's not a property of the core cmd shell (like it would be on unix). |
Given that it's the option that would cause more work for me, I'm certain we do it too 😄 |
Expansions are done in ExpandFileNamePattern |
@jaredpar, would this track only expanding wildcards deterministically or sorting all code file inputs deterministically? I would think we want to expand wildcards deterministically (since that is done by us) but would preserve any non-expanding inputs the user specified in the order they specified them. I would also think that we would preserve ordering of our expansions and ordering of user inputs relative to each other. That is, if the user passed in I think doing this is important since, as you mentioned, it does make some difference in some cases (such as partial class ordering). |
Yep. |
This makes the order of source file enumeration not depend on the platform (OS, FS, etc.) or culture. Fixes dotnet#10858
When you compile *.cs or *.vb, the compiler enumerates files to determine what to compile. It should sort the result so that the compilation is more deterministic.
The relevant code has a bottleneck in
Roslyn.Utilities.PortableShim.Directory.EnumerateFiles
where the sorting could take place.The text was updated successfully, but these errors were encountered: