Make Generate deterministic and add CI verification step#89
Open
jaredpar wants to merge 5 commits into
Open
Conversation
The file system enumeration in FindDlls was non-deterministic because Directory.GetFiles does not guarantee ordering, and the ordering varies across operating systems. Fix by: 1. Collecting all results into a list instead of yielding immediately 2. Normalizing path separators to forward slash for consistent sorting 3. Sorting by relative path using ordinal comparison This ensures the generated output is identical regardless of OS or file system enumeration order. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Runs the generator after restore and fails the build if there are any uncommitted diffs, ensuring PRs always include freshly generated output. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Path.Join uses the OS-specific separator between the prefix and the relative path, producing different output on Windows vs Linux. Replace with string interpolation using a consistent forward slash separator since MSBuild handles both styles. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
On Linux, Substring(packagePrefix.Length) produces a leading / in the
relative path. Combined with the interpolated /, this caused // in the
output. TrimStart('/') after normalization ensures no leading separator.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add .gitattributes to enforce LF line endings and normalize the generator output with ReplaceLineEndings to always produce LF. This ensures the generator produces identical output on Windows and Linux, making the CI verification step pass on both platforms. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The
Generatetool's output was non-deterministic becauseDirectory.GetFilesdoes not guarantee enumeration order, and different OSes return files in different orders. This meant running the generator on Linux vs Windows could produce different Generated.cs/targets files even with identical inputs.Approach
FindDlls, collect results into a list instead of yielding immediately, normalize path separators to/, and sort by relative path usingStringComparison.Ordinal. This ensures identical output regardless of OS or filesystem behavior.