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

Editorconfig in nuget package is not respected if slashes in source file path do not exactly match slashes in .editorconfig path #72657

Closed
dibarbet opened this issue Mar 21, 2024 · 1 comment · Fixed by #73100
Assignees
Milestone

Comments

@dibarbet
Copy link
Member

dibarbet commented Mar 21, 2024

This was originally found when doing this PR - dotnet/razor#10139

Arcade sets the NugetPackageRoot based on the NUGET_PACKAGES folder. Arcade will normalize the NugetPackageRoot (add a trailing slash).

If NUGET_PACKAGES does not include a trailing slash, the NugetPackageRoot will have one (appended by arcade) and they do not match:
image

This causes source file paths to be passed to the compiler with a double trailing slash \\ whereas the .editorconfig gets passed with a single trailing slash \
image
csc editorconfig arg:

/analyzerconfig:C:\Users\dabarbet\source\repos\EditorConfigNugetRepro\.packages\nugetpackagewitheditorconfig\1.0.0\contentFiles\cs\netstandard2.0\.editorconfig

csc source file arg

C:\Users\dabarbet\source\repos\EditorConfigNugetRepro\.packages\\nugetpackagewitheditorconfig\1.0.0\contentFiles\cs\netstandard2.0\Class1.cs

Both files are successfully read by the compiler, however it doesn't figure out that the nuget pkg source file belongs to the nuget package .editorconfig.

To repro, checkout and run the repro.ps1 script here - https://github.com/dibarbet/EditorConfigNugetRepro/tree/main
Binlog from the failing version in mismatch.zip
mismatch.zip

Related NuGet issue which is likely the source of the mismatches - NuGet/Home#7968

@dibarbet dibarbet self-assigned this Mar 21, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 21, 2024
@dibarbet dibarbet changed the title Editorconfig in nuget package is not respected when NUGET_PACKAGES does not end with trailing slash Editorconfig in nuget package is not respected when NUGET_PACKAGES does not match NugetPackageRoot Mar 22, 2024
@dibarbet dibarbet changed the title Editorconfig in nuget package is not respected when NUGET_PACKAGES does not match NugetPackageRoot Editorconfig in nuget package is not respected if slashes in source file path do not exactly match slashes in .editorconfig path Mar 22, 2024
@dibarbet dibarbet assigned chsienki and unassigned dibarbet Mar 22, 2024
@ToddGrun ToddGrun removed the untriaged Issues and PRs which have not yet been triaged by a lead label Mar 22, 2024
@jaredpar
Copy link
Member

jaredpar commented Apr 1, 2024

It seems like the only thing we could do in the compiler is attempt to normalize the path here. Essentially say that if we see \\ in a path then we normalize that to simply \. That is probably safe to do (can't think of any file system that allows \\ in a file path).

@jaredpar jaredpar added the Bug label Apr 1, 2024
@jaredpar jaredpar assigned jjonescz and unassigned chsienki Apr 1, 2024
@jaredpar jaredpar added this to the 17.11 milestone Apr 1, 2024
jaredpar added a commit to dotnet/razor that referenced this issue Apr 4, 2024
Issue a warning when `%NUGET_PACKAGES%` doesn't have a trailing slash
until the associatede issue is fixed.

dotnet/roslyn#72657
jaredpar added a commit to dotnet/razor that referenced this issue Apr 5, 2024
Issue a warning when `%NUGET_PACKAGES%` doesn't have a trailing slash
until the associatede issue is fixed.

dotnet/roslyn#72657
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants