Visual Studio 2022 Support
Installed product versions
- Visual Studio: 2022 All Versions
Description
Make the extension available in Visual Studio 2022.
Steps to recreate
- Download the extension installer.
- Run the installer.
Current behavior
Message that it is already installed to all applicable products appears even though it is not installed in Visual Studio 2022. It is also not listed in Online Extensions in Manage Extensions Visual Studio 2022.
Expected behavior
Installs and works in Visual Studio 2022.
Note: Sorry for the all the extra details. I probably could have stopped with the title on this one.
Also looking for this 🙂
Guess we can tell who the early adopters are, haha XD
There is already a PR for this #817
Thanks all for jumping on this quickly. There are indeed some compatibility breaking changes in VS2022. I believe last I heard it was expected that for all extensions the code would have to be branched and separate releases made targeting different versions of Visual Studio. For the time being I would keep the dev and release branches pointing to the existing VS2017/VS2019 version, tied into the CI pipeline, etc. We'll end up creating a new vs2022 branch and I'm still thinking about the other implications.
It looks like 2 PRs have started, #817 and #818. It looks like #818 might have gone farther with following recommendations. Thanks for links @scottkuhl as there may be some non-obvious changes we need to make to support the changes. Testing those out and seeing what issues come up (e.g. the settings dialog not opening in one) is super helpful and appreciated. <3
Hey all, I've been working on the VS2022 upgrade. I decided to start fresh on a new vs2022 branch and follow the instructions for multi-targeting VS versions based on https://docs.microsoft.com/en-us/visualstudio/extensibility/migration/update-visual-studio-extension?view=vs-2022 vs. building on top of #818 which is VS2022-only. I have to say these are far more detailed instructions than have ever been provided before and I really appreciate them.
What is done
-
"Modernize your projects". I attempted this a few years ago and encountered several issues at the time. This worked pretty smoothly this time around and closes #643. CodeMaid still worked as expected at this checkpoint.
-
Created a shared project called
CodeMaidShared, migrated code and linked resources. Deviations: -- I haven't done the same with CodeMaid.IntegrationTests yet. I wanted to prove it out with the main project first. -- Instead of moving all the resource files and having both projects utilize links to the new location, I left all files in their original location and only have the new project performing links. This seems like it should(tm) be the same difference to me and saved a chunk of effort. -
Created the new VS2022 VSIX called
CodeMaid.VS2022with necessary links/updates. -
VS2017 can compile and generate the original CodeMaid VSIX successfully.
-
VS2022 can compile and generate the new CodeMaid 2022 VSIX successfully.
-
i.e. the migration instructions above are complete.
Where it stands
The extension loads successfully into the VS2022 Preview IDE, but that's about it. Some very limited functionality is working (e.g. build progress tool window) but most core functionality is not working for different reasons.
Cleaning/Joining
System.NotImplementedException is thrown when trying to use the EnvDTE.TextDocument.ReplacePattern API. I'm curious if this is related to switching from explicit EnvDTE references to the general Microsoft.VisualStudio.SDK package and if it's not targeting the correct version or needs an explicit binding redirect.
Digging
FileNotFoundException: Could not load file or assembly 'SteveCadwallader.CodeMaid, Culture=neutral' or one of its dependencies. The system cannot find the file specified. I'm curious if this is related to switching to a shared project and the XAML references are not working as expected. The same issue happens for other UI dialogs (e.g. Options and About dialogs).
Reorganizing
System.NotImplementedException is thrown when trying to use the EnvDTE.EditPoint.FindPattern API. This is very similar to above.
What is next
I'll be reaching out to Microsoft to see if they can provide any technical guidance on those issues. I'm sure we can work through them but if they have any hints that would certainly help. The vs2022 branch is published and I will gladly accept PRs against it.
An update:
I've been working with Microsoft on some of the issues above. I think we've got the Digging issue figured out but unfortunately with Preview 3.1 I'm no longer able to get the extension to load (i.e. a step backwards) so I haven't been able to test it.
The current error:
<entry>
<record>2198</record>
<time>2021/09/03 12:14:20.645</time>
<type>Error</type>
<source>VisualStudio</source>
<description>SetSite failed for package [CodeMaidPackage]Source: 'SteveCadwallader.CodeMaid' Description: Method not found: 'Void EnvDTE._dispBuildEvents_OnBuildBeginEventHandler..ctor(System.Object, UIntPtr)'.
System.MissingMethodException: Method not found: 'Void EnvDTE._dispBuildEvents_OnBuildBeginEventHandler..ctor(System.Object, UIntPtr)'.
 at SteveCadwallader.CodeMaid.CodeMaidPackage.<RegisterEventListenersAsync>d__36.MoveNext()
 at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
 at SteveCadwallader.CodeMaid.CodeMaidPackage.RegisterEventListenersAsync()
 at SteveCadwallader.CodeMaid.CodeMaidPackage.<InitializeAsync>d__32.MoveNext() in C:\src\codemaid\CodeMaidShared\CodeMaidPackage.cs:line 202
--- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
 at Microsoft.VisualStudio.Shell.AsyncPackage.<>c__DisplayClass20_0.<<Microsoft-VisualStudio-Shell-Interop-IAsyncLoadablePackageInitialize-Initialize>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
 at Microsoft.VisualStudio.Threading.JoinableTask.<JoinAsync>d__76.MoveNext()</description>
<guid>{4C82E17D-927E-42D2-8460-B473AC7DF316}</guid>
<hr>80131513</hr>
<errorinfo></errorinfo>
</entry>
While I'm waiting to hear back if anybody has ideas I'm all ears. Also if you want to play around the vs2022 branch is available. We'll get there!
@codecadwallader Did you manage to work out the error you mentioned above? Would love to know the progress on this.
I recently started using VS2022 Preview 4 and I am really missing the "Find in Solution Explorer" feature. I'm really hoping CodeMaid gets enabled soon.
I recently started using VS2022 Preview 4 and I am really missing the "Find in Solution Explorer" feature. I'm really hoping CodeMaid gets enabled soon.
There is a built in Hotkey for that.
On my German system it is CTRL + ß, s
On English systems, it should be CTRL + [, s according to https://stackoverflow.com/a/55025095/1378307
@kotx I did get through the SetSite error. It was actually just user error on my part, wrong startup project selected 🤦
I'm making progress on issue 2 (UI resolution using a shared project) but it's still in back and forth with Microsoft. It will mean refactoring the paths for a number of items but in particular trying to set the Application.ResourceAssembly which seems to be needed in shared contexts is not working as expected and provides the following error message:
IOException: Assembly.GetEntryAssembly() returns null. Set the Application.ResourceAssembly property or use the pack://application:,,,/assemblyname;component/ syntax to specify the assembly to load the resource from.
I haven't made any headway on related issues 1 and 3 about not implemented APIs. I've been hoping newer preview editions would catch up and fill out more of the API but as of Preview 4.1 they are still not implemented.
It's slow going, but continuing to work on it and as always help is welcome!
A lot of the challenge we're running into is trying to switch to a new shared project infrastructure in order to support both VS2017/VS2019 and VS2022 which introduces breaking compatibility changes. I still think this is the right way to go going forwards and is the recommended and documented path too, however a shortcut could be a direct upgrade to a VS2022-only version of CodeMaid. This would only be in a branch and would get abandoned eventually. It would be interesting to see if it encountered some of the same API issues or if they were only an issue with the shared project approach.
Status update: it looks like we've got issue 2 (UI resolution) worked out thanks to some help from Microsoft. 🎉 We needed to utilize Assembly.GetExecutingAssembly vs. GetEntryAssembly and the timing was off for when we were adding it. This seems to be required for VS2022 only, VS2017 doesn't need it but also doesn't seem to be harmed by it in some quick regression testing.
So what that all of the UI elements are appearing! The Spade (digging) window is not showing any content yet because while the code model is building successfully when we go to find the regions (not a part of the code model) the same missing API FindPattern that is issue 1 and 3 is used and throws an error.
I'm continuing to work with them and all the latest changes are pushed up into the vs2022 branch for anyone who would like to explore.
I got a VS2022 survey and I said it was a no-go because it is missing code maid.
I can't wait till this is finished, great work out there, code maid has been a MUST for me for years now .
I'm very much interested in this one, glad it is already being worked upon, thank you all!
Good news status update:
#847 was made by @olegtk to handle the FindPattern/ReplacePattern APIs not being supported in VS2022. These weren't listed as removed APIs so I've opened this issue in the docs: https://github.com/MicrosoftDocs/visualstudio-docs/issues/7148
There is a newer IFindService that was introduced with VS2019 which is now used instead. This migration by @olegtk was a huge help as find/replace is a pretty core pattern and was blocking a lot of functionality. This is a pretty significant change so some regression testing eyes would be greatly appreciated.
We'll have to drop support for VS2017 with the next release since there isn't an API that works from VS2017-VS2022. I haven't updated the code base yet with making VS2019 the minimum required version but this will be CodeMaid v12 with VS2019+VS2022 support.
I'm also planning to drop the integration tests. They haven't worked since pre-VS2017 (see #467 for details) and it doesn't make sense to migrate them to the new shared project structure if they won't work anyways. It's a bummer and I'm hopeful to bring them back from the source control archives some day if they become supported again.
I'm very happy to say we've got an initial version that is available for alpha testing with VS2022 only:
CodeMaid.VS2022.20211014T145200.vsix.zip
This will have to be manually installed and uninstalled to VS2022 since it is out of band. Some new CI/CD pipeline updates will need made since VS2019 and VS2022 will have to compile/install separately.
If you like to live dangerously and would like to help out with testing this version out it would be greatly appreciated! As you encounter issues please spin up new GitHub issues and clearly indicate that it is for VS2022 (part of the issue template).
Thanks all for the help and enjoy!
Just installed the Alpha on my VS2022. The primary features I've been missing (Find in solution explorer, Reorganze and Cleanup) are all working perfectly. This is fantastic, keep up the good work!
What a wonderful new! I was looking forward to it! I'm a big fan of the "Ctrl+M, Space" cleanup shortcut. I've been testing it here... and from what I can see it's not working with .razor files
@pierrebrito was it working with .razor files in VS 2019? I just tried and seems not to me.