static IEnumerable <object> GetParameterValues(ParameterInfo[] parInfos) { foreach (var pInfo in parInfos) { var param = SampleGenerator.GenerateSample(pInfo.ParameterType); if (param == null) { throw new NullReferenceException("No matrix params"); } else { yield return(param); } } }
void Init(ISymbol symbol) { var asemblyName = symbol.ContainingAssembly.Name; if (asemblyName == "MyAshes") { return; } var appDTE = (DTE2)Package.GetGlobalService(typeof(SDTE)); var curProj = appDTE.ActiveDocument.ProjectItem.ContainingProject; var vsCurProj = (VSProject)curProj.Object; var asmFilePath = vsCurProj.References.OfType <Reference>().FirstOrDefault(r => r.Name == asemblyName).Path; var className = symbol.ContainingType.ToDisplayString(Microsoft.CodeAnalysis.SymbolDisplayFormat.FullyQualifiedFormat).Replace("global::", ""); var functionName = symbol.Name; var paramTypes = new List <Type>(); foreach (var parm in ((IMethodSymbol)symbol).Parameters) { paramTypes.Add(parm.Type.Name.ToType()); } var objAssembly = Assembly.LoadFrom(asmFilePath); classType = objAssembly.GetType(className); classInstance = SampleGenerator.GenerateSample(classType); if (!IsValid(functionName, paramTypes)) { return; } MakeMethod(symbol); }