SharpCrafters Forum – Failing on multiple NonNull attributes

SharpCrafters Support Forum

        


Failing on multiple NonNull attributes Expand / Collapse
Author
Message
Posted 11/20/2008 10:33:15 PM


Community Member
I'm trying to use Torch.dbc and running into something odd.

if you have a method signature like
public void TwoParam([NonNull]string arg1, [NonNull]string arg2)

the NonNull check only gets applied to the first parameter. poking around in the code, i saw this:

if (!methods.ContainsKey(paramDef.Parent))
{
  codeWeaver.AddMethodLevelAdvice(new NonNullParameterAdvice(paramDef),
                                                           new Singleton<MethodDefDeclaration>(paramDef.Parent),
                                                           JoinPointKinds.BeforeMethodBody,
                                                           null);
 methods.Add(paramDef.Parent, paramDef.Parent);
}

so, when the second attribute comes in, the method is already in the collection so the advice doesn't get applied.

Is there a reason this is here or should it be removed?
Post #3296
Posted 11/21/2008 9:51:58 AM


Gael Fraiteur

SharpCrafters
I made some corrections to this plug-in for compatibility with PostSharp 1.5 (you can apply NonNull on interfaces). it is available in the "1.5" folder.

-gael
Post #3297
Posted 11/21/2008 1:05:52 PM


Community Member
Gael,

i got the latest code from the googlecode svn and that methods.ContainsKey check is still there. is that code not up to date or is there a reason that NonNull can only be applied to one parameter of a method?
Post #3298
Posted 11/21/2008 1:12:36 PM


Gael Fraiteur

SharpCrafters
Michael,

I don't know. You should contact the original author. I actually don't support this project.

-gael
Post #3299
Posted 11/21/2008 2:46:01 PM


Community Member
Gotcha. i only saw your name on the code in SVN so i assumed you wrote it  <!-- s:lol: --> <!-- s:lol: -->

i've posted an issue to the googlecode repository.
Post #3300
« Prev Topic | Next Topic »


All times are GMT +1:00, Time now is 11:46am

Powered By InstantForum.NET v4.1.4 © 2010
Execution: 0.086. 8 queries. Compression Disabled.