pamidur / aspect-injector

AOP framework for .NET (c#, vb, etc)
Apache License 2.0
770 stars 115 forks source link

AspectCodeFixProvider and MixinCodeProvider are throwing FileNotFoundException in VS 2022 #179

Closed jeremyj01 closed 2 years ago

jeremyj01 commented 2 years ago

Environment (please complete the following information):

Describe the bug The AspectCodeFixProvider and the MixinCodeFixProvider are throwing a System.IO.FileNotFoundException.

To Reproduce Open a project using Visual Studio 2022 that contains one or more classes that use an aspect that was created using AspectInjector. The advice for the overridden Handle method should be Kind.Around. You will see the following errors at the top of VS studio:

'AspectCodeFixProvider' encountered an error and has been disabled. Show Stack Trace Enable Enable and ignore future errors 'MixinCodeFixProvider' encountered an error and has been disabled. Show Stack Trace Enable Enable and ignore future errors

This doesn't seem to affect the success of the build or runtime behavior, but it is concerning.

Exception stacktrace ``` System.IO.FileNotFoundException : Could not load file or assembly 'AspectInjector.Rules, Version=2.7.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. at AspectInjector.Analyzer.CodeFixes.AspectCodeFixProvider.get_FixableDiagnosticIds() at Microsoft.CodeAnalysis.CodeFixes.CodeFixService.GetAndTestFixableDiagnosticIds(CodeFixProvider codeFixProvider) at System.Collections.Immutable.ImmutableInterlocked.GetOrAdd[TKey,TValue](ImmutableDictionary`2& location,TKey key,Func`2 valueFactory) at Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunction[T](IExtensionManager extensionManager,Object extension,Func`1 function,T defaultValue) ```
pamidur commented 2 years ago

Hi @jeremyj01 , thanks for report, will look at shortly!

jeremyj01 commented 2 years ago

Just a side note...this is one of my FAVORITE .net packages!

pamidur commented 2 years ago

@jeremyj01, thank you! It means much!

pamidur commented 2 years ago

Hi @jeremyj01 , I tried to reproduce this bug without success. Created aspect with Around advice and two classes using it within the same file. No errors. I tend to believe (deducting from stacktrace you sent) that it was a Visual Studio glitch. In stackstace it mentions AspectInjector.Rules v2.7.0 though you're using 2.7.2 . Restarting VS should help.

If it doesn't, please send me a minimal file that reproduces the bug, that would help a lot!

jeremyj01 commented 2 years ago

I back checked myself and realized I never merged my updates to using 2.7.2. I'll take care of that shortly and report back. Sorry if I raised an unnecessary alarm.

jeremyj01 commented 2 years ago

@pamidur so...chock this one up to a PEBKAC error (Problem Exists Between Keyboard And Chair). I updated a feature branch to 2.7.2, but never PR'd them to promote the updates to develop and finally master. Once I did that, I no longer see the error.

Thanks for prodding me to recheck my work, my good dude! 😄