error : Parameter name: genericArguments

Technical questions about PostSharp Laos.

error : Parameter name: genericArguments

Postby ddignam on Wed Apr 09, 2008 10:03 pm

Not sure if this should work or not, it would be cool if it should 8-)

Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using PostSharp.Extensibility;
using PostSharp.Laos;

[assembly: Bar.Foo(AttributeTargetAssemblies = "System.Core", AttributeTargetTypes = "System.Collections.Generic.HashSet*", AttributeTargetMembers = "Add")]

namespace Bar
{
    [Serializable]
    public class Foo : OnMethodInvocationAspect
    {
        public override void OnInvocation(MethodInvocationEventArgs eventArgs)
        {
        }
    }
}


It gives the following error, which is presuemably related to the generic nature of the add method I want to intercept?

PostSharp 1.0 [1.0.8.316] - Copyright (c) Gael Fraiteur, 2005-2008.
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : Value cannot be null.
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : Parameter name: genericArguments
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error :
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : Server stack trace:
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : at PostSharp.ExceptionHelper.AssertArgumentNotNull(Object value, String parameterName)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : at PostSharp.CodeModel.TypeSignatures.GenericTypeInstanceTypeSignature..ctor(INamedType genericDeclaration, IList`1 genericArguments)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : at PostSharp.Laos.Weaver.OnMethodInvocationAspectWeaver.GetCalledMethodSpec(MethodDefDeclaration calledMethodDef, GenericMap callerToWrapperGenericMap, GenericMap callerToWrapperInverseGenericMap, IMethod& calledMethodSpec, IType& calledMethodDeclaringTypeSpec) in p:\open\branches\1.0\Laos\PostSharp.Laos.Weaver\OnMethodInvocationAspectWeaver.cs:line 381
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : at PostSharp.Laos.Weaver.OnMethodInvocationAspectWeaver.ImplementWrapperMethod(TypeDefDeclaration containerType, MethodDefDeclaration calledMethodDef, IType delegateType, IField aspectRuntimeInstanceFieldField, GenericMap callerToWrapperGenericMap, GenericMap callerToWrapperInverseGenericMap, InstructionWriter instructionWriter, Boolean hasDelocalizedImplementation, Boolean forceStatic) in p:\open\branches\1.0\Laos\PostSharp.Laos.Weaver\OnMethodInvocationAspectWeaver.cs:line 579
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : at PostSharp.Laos.Weaver.OnMethodInvocationAspectWeaver.GetWrapperMethodSpec(IMethod calledMethod, IField customAttributeInstanceField, InstructionWriter instructionWriter, TypeDefDeclaration originatingType) in p:\open\branches\1.0\Laos\PostSharp.Laos.Weaver\OnMethodInvocationAspectWeaver.cs:line 984
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : at PostSharp.Laos.Weaver.OnMethodInvocationAspectWeaver.PostSharp.CodeWeaver.IAdvice.Weave(WeavingContext context, InstructionBlock block) in p:\open\branches\1.0\Laos\PostSharp.Laos.Weaver\OnMethodInvocationAspectWeaver.cs:line 1050
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : at PostSharp.CodeWeaver.AdviceCollection.Weave(WeavingContext context, Int32 mask, InstructionBlock block, Boolean reverse)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : at PostSharp.CodeWeaver.Weaver.ProcessJoinPoint(JoinPointKindIndex joinPointKindBefore, JoinPointKindIndex joinPointKindInsteadOf, JoinPointKindIndex joinPointKindAfter, WeaverState state, MetadataDeclaration operand)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : at PostSharp.CodeWeaver.Weaver.ProcessBeforeInstruction(WeaverState state)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : at PostSharp.CodeWeaver.Weaver.Process(WeaverState state)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : at PostSharp.CodeWeaver.Weaver.WeaveMethod(MethodDefDeclaration method)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : at PostSharp.CodeWeaver.Weaver.Weave()
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : at PostSharp.CodeWeaver.WeaverTask.Execute()
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : at PostSharp.Extensibility.Project.ExecutePhase(String phase)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : at PostSharp.Extensibility.Project.Execute()
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : at PostSharp.Extensibility.PostSharpObject.ExecuteProjects()
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : at PostSharp.Extensibility.PostSharpObject.InvokeProjects(ProjectInvocation[] projectInvocations)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error : at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(121,3): error :

--
Dan
ddignam
 
Posts: 16
Joined: Mon Apr 07, 2008 5:07 pm
Full Name: Daniel Dignam
Company: Solidworks

Re: error : Parameter name: genericArguments

Postby gfraiteur on Thu Apr 10, 2008 8:25 am

It seems to be a bug. Could you please post a bug report with a repro case (this stack trace, the aspect + the method to which you apply it).

Thank you,

Gael
Gael Fraiteur, project leader
got good support? consider donating to the project.
gfraiteur
Site Admin
 
Posts: 608
Joined: Tue Dec 18, 2007 3:09 pm
Full Name: Gael Fraiteur
Company: postsharp.org

Re: error : Parameter name: genericArguments

Postby ddignam on Thu Apr 10, 2008 9:29 am

Hi Gael,

It appears to be the result of subclassing a generic collection

Code: Select all
   
class R : HashSet<String>
{
   public void AddString(String s)
   {
      Add(s);
   }
}


HashSet<String> works fine.

Thanks
ddignam
 
Posts: 16
Joined: Mon Apr 07, 2008 5:07 pm
Full Name: Daniel Dignam
Company: Solidworks

Re: error : Parameter name: genericArguments

Postby ddignam on Thu Apr 10, 2008 6:15 pm

Conirmed fixed in 344, not sure if this the right way of doing it or not ;-)

Thanks Gael !

--
Dan
ddignam
 
Posts: 16
Joined: Mon Apr 07, 2008 5:07 pm
Full Name: Daniel Dignam
Company: Solidworks


Return to PostSharp Laos