pamidur / aspect-injector

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

[2.8.2][macOS] error AI_FAIL: Aspect Injector processing has failed #220

Open Alex-Dobrynin opened 1 year ago

Alex-Dobrynin commented 1 year ago

After update to 2.8.2 from version 2.8.1 cannot build my netstandard2.1 lib, getting error mentioned in title. In macOS image

pamidur commented 1 year ago

Hi, thank you for the report! Would you be able to submit the whole build log or at other least parts related to Aspect Injectior?

On Thu, 13 Jul 2023, 09:02 Oleksandr Dobrynin, @.***> wrote:

After update to 2.8.2 from version 2.8.1 cannot build my netstandard2.1, getting error mentioned in title. In macOS [image: image] https://user-images.githubusercontent.com/23138430/253099846-892c7b5f-02e4-4053-aa84-63f175286db8.png

— Reply to this email directly, view it on GitHub https://github.com/pamidur/aspect-injector/issues/220, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7HZUAB4BMMBJRT57FX6I3XP4GHVANCNFSM6AAAAAA2IAYFTY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

pamidur commented 1 year ago

please let me know if 2.8.3-pre1 fixes it for you!

Alex-Dobrynin commented 1 year ago

the same

kerojiang commented 1 year ago

I got the same error on windows This is build log 2> AspectInjector|2.8.2: Found 0 aspects, 6 injections 2>AspectInjector|2.8.2 : error AI_ERR0: Processing failure: System.ArgumentException: Arg_ArgumentException 2> at Mono.Cecil.Pdb.ISymUnmanagedWriter2.OpenScope(Int32 startOffset, Int32& pRetVal) 2> at Mono.Cecil.Pdb.NativePdbWriter.DefineScope(ScopeDebugInformation scope, MethodDebugInformation info, MetadataToken& import_parent) 2> at Mono.Cecil.Pdb.NativePdbWriter.DefineScope(ScopeDebugInformation scope, MethodDebugInformation info, MetadataToken& import_parent) 2> at Mono.Cecil.Pdb.NativePdbWriter.Write(MethodDebugInformation info) 2> at Mono.Cecil.Cil.CodeWriter.WriteResolvedMethodBody(MethodDefinition method) 2> at Mono.Cecil.Cil.CodeWriter.WriteMethodBody(MethodDefinition method) 2> at Mono.Cecil.MetadataBuilder.AddMethod(MethodDefinition method) 2> at Mono.Cecil.MetadataBuilder.AddMethods(TypeDefinition type) 2> at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type) 2> at Mono.Cecil.MetadataBuilder.AddTypes() 2> at Mono.Cecil.MetadataBuilder.BuildTypes() 2> at Mono.Cecil.MetadataBuilder.BuildModule() 2> at Mono.Cecil.MetadataBuilder.BuildMetadata() 2> at Mono.Cecil.ModuleWriter.<>c.b__20(MetadataBuilder builder, MetadataReader ) 2> at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func3 read) 2> at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata) 2> at Mono.Cecil.ModuleWriter.Write(ModuleDefinition module, Disposable1 stream, WriterParameters parameters) 2> at Mono.Cecil.ModuleWriter.WriteModule(ModuleDefinition module, Disposable1 stream, WriterParameters parameters) 2> at Mono.Cecil.ModuleDefinition.Write(Stream stream, WriterParameters parameters) 2> at Mono.Cecil.ModuleDefinition.Write(WriterParameters parameters) 2> at Mono.Cecil.AssemblyDefinition.Write(WriterParameters parameters) 2> at FluentIL.PatcherBase.WriteAssembly(AssemblyDefinition assembly, Boolean writeSymbols, Boolean verbose) 2> at FluentIL.PatcherBase.Process(String assemblyFile, IAssemblyResolver resolver, Boolean optimize, Boolean verbose) 2> at FluentIL.PatcherBase.Process(String assemblyFile, IReadOnlyList1 references, Boolean optimize, Boolean verbose) 2> at AspectInjector.Compiler.Execute(String filename, IReadOnlyList`1 references, Boolean optimize, Boolean verbose). Please submit an issue to https://github.com/pamidur/aspect-injector 2>AspectInjector : error AI_FAIL: Aspect Injector processing has failed. See other errors.

real-zony commented 1 year ago

The macOS 13.4 also had the same issue. The version of AspectInjector is 2.8.2. It works normally in the Docker container of X64. My MacBook is M2 Max and uses the ARM version of dotnet (6.0.413).

real-zony commented 1 year ago

My temporary solution is to use Docker (x86) debugging in Rider (through Rosetta 2), but this makes the debugging very slow each time. Is there any update on this issue? Thank you. I tried version 2.8.3-pre1 but it still did not solve my issue.😔

pamidur commented 1 year ago

Could you please use 2.8.1 while I'm fixing this? Just to double check, 2.8.2 does not work for x86 and arm and 2.8.1 does not work only for arm Correct?

On Wed, 23 Aug 2023, 03:02 Zony, @.***> wrote:

My temporary solution is to use Docker (x86) debugging in Rider (through Rosetta 2), but this makes the debugging very slow each time. Is there any update on this issue? Thank you.

— Reply to this email directly, view it on GitHub https://github.com/pamidur/aspect-injector/issues/220#issuecomment-1688365024, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7HZUBT43MBTDOWQKARI73XWTCW7ANCNFSM6AAAAAA2IAYFTY . You are receiving this because you commented.Message ID: @.***>

real-zony commented 1 year ago

Could you please use 2.8.1 while I'm fixing this? Just to double check, 2.8.2 does not work for x86 and arm and 2.8.1 does not work only for arm Correct? On Wed, 23 Aug 2023, 03:02 Zony, @.> wrote: My temporary solution is to use Docker (x86) debugging in Rider (through Rosetta 2), but this makes the debugging very slow each time. Is there any update on this issue? Thank you. — Reply to this email directly, view it on GitHub <#220 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7HZUBT43MBTDOWQKARI73XWTCW7ANCNFSM6AAAAAA2IAYFTY . You are receiving this because you commented.Message ID: @.>

Of course, I rolled back to version 2.8.1, and it is working correctly.

dartasen commented 1 year ago

Same issue

pamidur commented 1 year ago

@real-zony , @dartasen, @Alex-Dobrynin , Unfortunatelly I don't have arm based mac machine to test it , so I have to rely on you. Could you please confirm that 2.8.1 works fine on arm machine ?

Alex-Dobrynin commented 1 year ago

Yes, 2.8.1 it works on mac m1

pamidur commented 1 year ago

Hey guys, could you please try 2.8.3-pre2 ?

dartasen commented 1 year ago

Hey guys, could you please try 2.8.3-pre2 ?

Same issue, unable to build image

pamidur commented 1 year ago

do you use Rosetta ?

serfend commented 11 months ago

when your method return is not void,you should only use Kind.Around


        [Advice(Kind.Around, Targets = Target.Method)]
        public object OnEnter([Argument(Source.Name)] string name,
            [Argument(Source.Arguments)] object[] args,
            [Argument(Source.Type)] Type hostType,
            [Argument(Source.Target)] Func<object[], object> target,
            [Argument(Source.Triggers)] System.Attribute[] triggers)
        {
            var mutex = new Mutex(false, Name);
            mutex.WaitOne();
            var result = target(args);
            mutex.ReleaseMutex();
            return result;
        }
serfend commented 11 months ago

but while user use MVC , such error followed wont be shown.

AI_EA00 Advice 'OnEnter' must return 'object' for 'Around' advice   Test.Aspect-Injector.Failed D:\backup\0.Main\workspace\resources\Test.Aspect-Injector.Failed\Test.Aspect-Injector.Failed\Test.Aspect-Injector.Failed\MutexHandlerAttribute.cs   43  活动

thats unexpected.

serfend commented 11 months ago

you can refer to demo for a success running.

serfend commented 11 months ago

amazing , i move exactly same code into other project , same error occurred. windows11/vs2022 17.4.4.

AI_FAIL Aspect Injector processing has failed. See other errors.    ProjectCommon   
..\Common\AspectInjector    1   
serfend commented 11 months ago

i think i found where problem is,see docs

stilettk commented 10 months ago

I'm experiencing the same issue. I'm on Apple Silicon, my coworker with Mac on Intel doesn't have this problem.

Here is the detailed log:

     2>Target "_ASI_InjectAspectsCore" in file "/Users/stilettk/.nuget/packages/aspectinjector/2.8.3-pre2/buildTransitive/netstandard2.0/AspectInjector.targets" from project "/Users/stilettk/RiderProjects/loyalty/tests/Dodo.Loyalty.ComponentTests/Dodo.Loyalty.ComponentTests.csproj" (target "InjectAspects" depends on it):
       Set Property: _ProcessCmd="/Users/stilettk/.nuget/packages/aspectinjector/2.8.3-pre2/buildTransitive/netstandard2.0/../../build/_bin/osx-arm64/AspectInjector" -rf "/Users/stilettk/RiderProjects/loyalty/tests/Dodo.Loyalty.ComponentTests/obj/Debug/net7.0/Dodo.Loyalty.ComponentTests.dll._asi_refs" "/Users/stilettk/RiderProjects/loyalty/tests/Dodo.Loyalty.ComponentTests/obj/Debug/net7.0/Dodo.Loyalty.ComponentTests.dll"
       Task "Message" skipped, due to false condition; ( '$(AspectInjector_Debug)' == 'true' ) was evaluated as ( 'false' == 'true' ).
       Using "Exec" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
       Task "Exec"
         Task Parameter:Command="/Users/stilettk/.nuget/packages/aspectinjector/2.8.3-pre2/buildTransitive/netstandard2.0/../../build/_bin/osx-arm64/AspectInjector" -rf "/Users/stilettk/RiderProjects/loyalty/tests/Dodo.Loyalty.ComponentTests/obj/Debug/net7.0/Dodo.Loyalty.ComponentTests.dll._asi_refs" "/Users/stilettk/RiderProjects/loyalty/tests/Dodo.Loyalty.ComponentTests/obj/Debug/net7.0/Dodo.Loyalty.ComponentTests.dll"
         Task Parameter:EchoOff=True
         Task Parameter:IgnoreExitCode=True
         Task Parameter:WorkingDirectory=/Users/stilettk/.nuget/packages/aspectinjector/2.8.3-pre2/buildTransitive/netstandard2.0/
         /var/folders/y5/bg13rk8164n771x2jq7892ph0000gn/T/MSBuildTempstilettk/tmpaa7b21c171eb4634b4ae0d25bde46562.exec.cmd: line 2: 29017 Killed: 9               "/Users/stilettk/.nuget/packages/aspectinjector/2.8.3-pre2/buildTransitive/netstandard2.0/../../build/_bin/osx-arm64/AspectInjector" -rf "/Users/stilettk/RiderProjects/loyalty/tests/Dodo.Loyalty.ComponentTests/obj/Debug/net7.0/Dodo.Loyalty.ComponentTests.dll._asi_refs" "/Users/stilettk/RiderProjects/loyalty/tests/Dodo.Loyalty.ComponentTests/obj/Debug/net7.0/Dodo.Loyalty.ComponentTests.dll"
         Output Property: _AspectExitCode=137
       Done executing task "Exec".
       Using "Error" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
       Task "Error"
         Task Parameter:File=AspectInjector
         Task Parameter:Text=Aspect Injector processing has failed. See other errors.
         Task Parameter:Code=AI_FAIL
     2>AspectInjector : error AI_FAIL: Aspect Injector processing has failed. See other errors. [/Users/stilettk/RiderProjects/loyalty/tests/Dodo.Loyalty.ComponentTests/Dodo.Loyalty.ComponentTests.csproj]
       Done executing task "Error" -- FAILED.
     2>Done building target "_ASI_InjectAspectsCore" in project "Dodo.Loyalty.ComponentTests.csproj" -- FAILED.
pamidur commented 10 months ago

I'm really sorry my Mac users, since I don't have it is hard to figure out what actually goes wrong. @stilettk do you have Rosetta installed?

stilettk commented 10 months ago

@stilettk do you have Rosetta installed?

I didn't explicitly install it, but according to this, I have it installed.

stilettk commented 10 months ago

@pamidur FYI in 2.8.3-pre3 the problem persists

Build log ``` 2>Target "_ASI_InjectAspectsCore" in file "/Users/stilettk/.nuget/packages/aspectinjector/2.8.3-pre3/buildTransitive/netstandard2.0/AspectInjector.targets" from project "/Users/stilettk/RiderProjects/loyalty/tests/Dodo.Loyalty.ComponentTests/Dodo.Loyalty.ComponentTests.csproj" (target "InjectAspects" depends on it): Set Property: _ProcessCmd="/Users/stilettk/.nuget/packages/aspectinjector/2.8.3-pre3/buildTransitive/netstandard2.0/../../build/_bin/osx-arm64/AspectInjector" -rf "/Users/stilettk/RiderProjects/loyalty/tests/Dodo.Loyalty.ComponentTests/obj/Debug/net7.0/Dodo.Loyalty.ComponentTests.dll._asi_refs" "/Users/stilettk/RiderProjects/loyalty/tests/Dodo.Loyalty.ComponentTests/obj/Debug/net7.0/Dodo.Loyalty.ComponentTests.dll" Task "Message" skipped, due to false condition; ( '$(AspectInjector_Debug)' == 'true' ) was evaluated as ( 'false' == 'true' ). Using "Exec" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Task "Exec" Task Parameter:WorkingDirectory=/Users/stilettk/.nuget/packages/aspectinjector/2.8.3-pre3/buildTransitive/netstandard2.0/ Task Parameter:Command="/Users/stilettk/.nuget/packages/aspectinjector/2.8.3-pre3/buildTransitive/netstandard2.0/../../build/_bin/osx-arm64/AspectInjector" -rf "/Users/stilettk/RiderProjects/loyalty/tests/Dodo.Loyalty.ComponentTests/obj/Debug/net7.0/Dodo.Loyalty.ComponentTests.dll._asi_refs" "/Users/stilettk/RiderProjects/loyalty/tests/Dodo.Loyalty.ComponentTests/obj/Debug/net7.0/Dodo.Loyalty.ComponentTests.dll" Task Parameter:IgnoreExitCode=True Task Parameter:EchoOff=True /var/folders/y5/bg13rk8164n771x2jq7892ph0000gn/T/MSBuildTempstilettk/tmp3c20c11a47674faaaeb388be23585be7.exec.cmd: line 2: 35405 Killed: 9 "/Users/stilettk/.nuget/packages/aspectinjector/2.8.3-pre3/buildTransitive/netstandard2.0/../../build/_bin/osx-arm64/AspectInjector" -rf "/Users/stilettk/RiderProjects/loyalty/tests/Dodo.Loyalty.ComponentTests/obj/Debug/net7.0/Dodo.Loyalty.ComponentTests.dll._asi_refs" "/Users/stilettk/RiderProjects/loyalty/tests/Dodo.Loyalty.ComponentTests/obj/Debug/net7.0/Dodo.Loyalty.ComponentTests.dll" Output Property: _AspectExitCode=137 Done executing task "Exec". Using "Error" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Task "Error" Task Parameter:File=AspectInjector Task Parameter:Code=AI_FAIL Task Parameter:Text=Aspect Injector processing has failed. See other errors. 2>AspectInjector : error AI_FAIL: Aspect Injector processing has failed. See other errors. [/Users/stilettk/RiderProjects/loyalty/tests/Dodo.Loyalty.ComponentTests/Dodo.Loyalty.ComponentTests.csproj] Done executing task "Error" -- FAILED. 2>Done building target "_ASI_InjectAspectsCore" in project "Dodo.Loyalty.ComponentTests.csproj" -- FAILED. ```
pamidur commented 10 months ago

can you try https://www.nuget.org/packages/AspectInjector/2.8.3-pre3#supportedframeworks-body-tab ? and see if it helps if it still does not work, you can try adding

<PropertyGroup>
    <AspectInjector_UseRosetta>true</AspectInjector_UseRosetta>
  </PropertyGroup>

to your csproj

stilettk commented 10 months ago

What do you mean by trying https://www.nuget.org/packages/AspectInjector/2.8.3-pre3#supportedframeworks-body-tab? To use net20 or netstandard2.0? Unfortunately, I can't do this in my project because all references require newer versions.

AspectInjector_UseRosetta helped though. But I hope that this won't be a requirement because AspectInjector is a transitive dependency for us (from Allure.NUnit).

pamidur commented 10 months ago

it is there just to test it. It seems like Rosetta is going to be a requirement and after the next release it is going to be the only supported option. I just can't make it run on apple silicon without rosetta without having actual mac :(

gshuchi commented 3 months ago

Hey People! Install the terminal with Rosetta settings and this error will be gone after dotnet build command.