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

Analyzer template not working for accounts with long user names #601

Closed
MichaRotstein opened this issue Aug 31, 2020 · 7 comments · Fixed by #607
Closed

Analyzer template not working for accounts with long user names #601

MichaRotstein opened this issue Aug 31, 2020 · 7 comments · Fixed by #607

Comments

@MichaRotstein
Copy link

I just tried again to create C# analyzer codefix project with the new Version 16.8.0 Preview 2.0
I get:

image

I have now been trying to simply create and build the c# analyzer template which should be trivial for over a month with no luck. Many issues have been opened and get closed without this resolved.

@sharwell sharwell changed the title C# Codefix Analyzer template not working in 16.8.0 preview 2 Analyzer template not working for accounts with long user names Aug 31, 2020
@sharwell
Copy link
Member

I believe this is caused by the path being too long. Can you tell me the total number of characters appearing in the value for %USERPROFILE%? For every character we shorten the longest names, one additional character can appear in this path.

@MichaRotstein
Copy link
Author

MichaRotstein commented Aug 31, 2020

thanks @sharwell , it is:

USERPROFILE=C:\Users\Micha Rotstein

@sharwell
Copy link
Member

For me, the path is:

C:\Users\sam\AppData\Local\Microsoft\VisualStudio\16.0_80a394a5\VTC\45823ca21c203519dc399b38d579e61d\~PC\CSharpDiagnostic\CSharp\Extensibility\1033\CSharpDiagnostic.zip\ProjectTemplates\CSharp\Diagnostic\Test\Verifiers\CSRefactoringVerifier`1+Test.cs

This is 250 characters, so without special system configuration I would expect the template to work for a user with a username up to 13 characters. Micha Rotstein is 14 characters. ☹️ Removing one or more characters from the path to this template file should resolve the issue for you.

@MichaRotstein
Copy link
Author

OK thanks , how do I do that ? (without changing my username)

@sharwell
Copy link
Member

A proper fix requires modification to the templates themselves, or fixing the IDE to stop producing paths this long in the template cache. In the meantime, the three ways to fix this would be:

  1. Generate the project on a machine/account which is shorter, after which time it will work everywhere.
  2. Manually create the missing file(s) based on the expected content
  3. Delete CSharpRefactoringVerifier`1.cs and the VB equivalent, which means you can't test code refactorings but you might not need this anyway

@MichaRotstein
Copy link
Author

Sorry but I can't see how any of these solutions will work for me, I have never had these kind of issues with any other template.

Is there a way to provide us with a project based on the template without any modifications that builds ?

@sharwell
Copy link
Member

sharwell commented Aug 31, 2020

Sorry but I can't see how any of these solutions will work for me, I have never had these kind of issues with any other template.

Every template has a limit on the username length. This just happens to be the first one you used where the limit was less than 14. The difficult part now is figuring out exactly how long we need to support.

Is there a way to provide us with a project based on the template without any modifications that builds ?

Here are the templates for the two files that failed to generate:

https://github.com/dotnet/roslyn-sdk/blob/master/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Test/Verifiers/CSRefactoringVerifier%601+Test.cs
https://github.com/dotnet/roslyn-sdk/blob/master/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Test/Verifiers/VBRefactoringVerifier%601%2BTest.cs

You'll need to make the following changes:

  1. Rename the files to CSharpRefactoringVerifier`1+Test.cs and VisualBasicRefactoringVerifier`1+Test.cs, respectively
  2. Change the namespace $safeprojectname$ listed in the file to match the namespace that appears in the file CSharpRefactoringVerifier`1.cs that did generate successfully

sharwell added a commit to sharwell/roslyn-sdk that referenced this issue Sep 2, 2020
@sharwell sharwell added the fixed label Sep 3, 2020
sharwell added a commit to sharwell/roslyn-sdk that referenced this issue Mar 5, 2021
This is an easy way to get a couple more characters allowed in long user
names.

Related to dotnet#601
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.

2 participants