Skip to content
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

ApiCompat suppression file is not compatible between Windows and Linux #44851

Closed
Fresa opened this issue Nov 13, 2024 · 5 comments
Closed

ApiCompat suppression file is not compatible between Windows and Linux #44851

Fresa opened this issue Nov 13, 2024 · 5 comments
Labels
Area-ApiCompat untriaged Request triage from a team member

Comments

@Fresa
Copy link

Fresa commented Nov 13, 2024

Describe the bug

Generating a suppression file with ApiCompat generates different Right directives on Windows and Linux which isn't interchangeable.

To Reproduce

Example project: https://github.com/Fresa/Kafka.Protocol/blob/b190d4eb98fb66f176925bf5b63c03d774980235/Kafka.Protocol/Kafka.Protocol.csproj
Suppression file generated through Visual Studio in Windows: https://github.com/Fresa/Kafka.Protocol/blob/b190d4eb98fb66f176925bf5b63c03d774980235/Kafka.Protocol/CompatibilitySuppressions.xml

Clone the repo from the specified commit.
Running dotnet build on Linux fails with compatibility errors and Unnecessary suppressions found (the same suppressions found in the suppression file).
Run dotnet build /p:ApiCompatGenerateSuppressionFile=true on Linux. It will override CompatibilitySuppressions.xml changing all backslashes in the Right directives to forward slashes.
Running dotnet build on Windows fails with compatibility errors and Unnecessary suppressions found (the same ones in the generated suppression file).

It also fails if running with different configurations (Debug/Release), as the path will differ in the Right directive. Maybe that's intentional, even though the Left directive doesn't necessary say anything about the configuration used to compile the baseline.

Removing all the Right directives fixes the issue (it seems to be optional), but there doesn't seem to be anyway to configure ApiCompat to not generate the Right directive?

Further technical details

Ubuntu 22.04 (WSL)

.NET SDK:
Version: 8.0.404
Commit: 7b190310f2
Workload version: 8.0.400-manifests.589672c3
MSBuild version: 17.11.9+a69bbaaf5

Runtime Environment:
OS Name: ubuntu
OS Version: 22.04
OS Platform: Linux
RID: linux-x64
Base Path: /usr/share/dotnet/sdk/8.0.404/

Windows 11

Microsoft Visual Studio Community 2022 (64-bit)
Version 17.12.0

.NET SDK:
Version: 9.0.100
Commit: 59db016
Workload version: 9.0.100-manifests.c6f19616
MSBuild version: 17.12.7+5b8665660

Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.100\

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-ApiCompat untriaged Request triage from a team member labels Nov 13, 2024
Copy link
Contributor

@dotnet/area-infrastructure-libraries a new issue has been filed in the ApiCompat area, please triage

@ViktorHofer
Copy link
Member

ViktorHofer commented Nov 13, 2024

Ack. Are you running APICompat as part of the build process (it usually only runs on Pack) by setting an additional property?

@Fresa
Copy link
Author

Fresa commented Nov 13, 2024

I use Microsoft.DotNet.ApiCompat.Task with ApiCompatValidateAssemblies turned on.

@ViktorHofer
Copy link
Member

ViktorHofer commented Nov 13, 2024

OK, yes. That feature is experimental at the moment. You can set the following items to transform the left and right paths to a platform agnostic and/or relative path: https://github.com/dotnet/runtime/blob/38e4ba60408fbe924b3edfbf4cbf8b1465fdc16a/eng/resolveContract.targets#L98-L105

This is just our usage in runtime. The item include supports a regex pattern in which you can use to capture groups. The item's ReplacementString metadata is a regex replace pattern in which you can reference on the captured item groups.

@Fresa
Copy link
Author

Fresa commented Nov 13, 2024

Thanks, that seems to have done the trick! 🎉

@Fresa Fresa closed this as completed Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-ApiCompat untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

2 participants