corvus-dotnet / Corvus.JsonSchema

Support for Json Schema validation and entity generation
Apache License 2.0
98 stars 9 forks source link

Long generated paths break Visual Studio UI #390

Closed shuebner closed 3 weeks ago

shuebner commented 1 month ago

TL;DR: Corvus could shorten generated file paths for better compatibility with Visual Studio UI.

This is not strictly your fault, but still an issue when working with Corvus-generated code in Visual Studio:

Corvus code generation uses very long file paths. That can become a problem even when having long paths activated in Windows (and GIT).

I got into the situation today where Visual Studio 2022 (17.10.4) shows red underlined errors in its editor (on the AsInt32() method in this case, claiming it does not exist). It would build successfully though. Also the dotnet CLI built successfully.

The file where the method was, was a *.Number.cs whose full path is 261 characters long. I think this is not a coincidence.

When I copied the whole code folder to plain C:\ and the issue was gone. This makes me believe there is some issue with long file paths (or file names) in Visual Studio itself (maybe related to https://learn.microsoft.com/en-us/answers/questions/1666150/ms-visual-studio-2022-not-able-to-open-source-file).

mwadams commented 1 month ago

This is absolutely not a coincidence!

Thanks for opening this issue - I will add something to limit and uniqueify overlong file paths.

It is depressing that we still have to deal with this in 2024...

shuebner commented 1 month ago

btw, the long file names also break the VS-internal git diff viewer.

mwadams commented 3 weeks ago

Fixed in #393 - please try the Preview packages on nuget.