I am working on a new JustCode analysis rule. I query for a particular IMethodInvocation that has a specific identifier.
foreach (IMethodInvocation mi in fileModel.All<IMethodInvocation>().Where(m => m.Identifier.Text == "IsNumeric"))In the object "mi", There is an Arguments Collection(?). Under there is another Arguments Collection(again ?). I am having problems finding the particular IArgument object (there's only 1 argument for IsNumeric in VB).
I have tried everything that I can think of to access the IArgument in IArguments[]. However, I usually get something about cannot convert a #2W.#xZ as an IArgument. Here is my latest try that failed miserably!
foreach (var arg in args.ToEnumerable<IArguments>()){ IMemberAccess ma = (IArgument)arg.Expression; if ((IArgument)arg.Expression.Type.Name.ToUpper() == "STRING") { mi.AddCodeMarker(Constants.EM110WarningExampleID, this, Constants.EM110FixText); }}
Can someone please post some sample code on how to iterate through the collection of Arguments so that I may evaluate each one (in this case, one)? When I do a "QuickWatch", I get this expression when I drill down into the Argument itself...
(new System.Linq.SystemCore_EnumerableDebugView<Telerik.JustCode.CommonLanguageModel.IArgument>(mi.Arguments.Arguments as #2W.#xZ<Telerik.JustCode.CommonLanguageModel.IArgument>))).Items[0])
Any help is greatly appreciated!
Thanks,
Jim Evans
Application Architect