public static ITypeInfo ResolveGenericType(ITypeInfo genericType, object[] parameters, IParameterInfo[] parameterInfos) { bool sawNullValue = false; ITypeInfo matchedType = null; for (int idx = 0; idx < parameterInfos.Length; ++idx) { var parameterType = parameterInfos[idx].ParameterType; if (parameterType.IsGenericParameter && parameterType.Name == genericType.Name) { object parameterValue = parameters[idx]; if (parameterValue == null) sawNullValue = true; else if (matchedType == null) matchedType = Reflector.Wrap(parameterValue.GetType()); else if (matchedType.Name != parameterValue.GetType().FullName) return ObjectTypeInfo; } } if (matchedType == null) return ObjectTypeInfo; return sawNullValue && matchedType.IsValueType ? ObjectTypeInfo : matchedType; }
public override IEnumerable<Attribute> GetAttributes(ITypeInfo typesInfo) { if (typesInfo.Type != typeof(PENACustomer)) yield break; var xpandNavigationItemAttribute = new XpandNavigationItemAttribute(Module.Captions.PropertyEditors + "Null Able properties", "PENACustomer_ListView"); yield return xpandNavigationItemAttribute; yield return new WhatsNewAttribute(new DateTime(2011, 1, 28), xpandNavigationItemAttribute); }
public virtual int CompareTypeInfosByNameAndPriority(ITypeInfo x, ITypeInfo y) { if (x == y) { return 0; } if (x.Key == Emitter.ROOT) { return -1; } if (y.Key == Emitter.ROOT) { return 1; } var xTypeDefinition = this.TypeDefinitions[x.Key]; var yTypeDefinition = this.TypeDefinitions[y.Key]; var xPriority = this.GetPriority(xTypeDefinition); var yPriority = this.GetPriority(yTypeDefinition); if (xPriority == yPriority) { return xTypeDefinition.FullName.CompareTo(yTypeDefinition.FullName); } return -xPriority.CompareTo(yPriority); }
private bool IsValidFixtureType(ITypeInfo typeInfo, ref string reason) { if (typeInfo.IsAbstract) { reason = string.Format("{0} is an abstract class", typeInfo.FullName); return false; } if (!typeInfo.HasConstructor(new Type[0])) { reason = string.Format("{0} does not have a default constructor", typeInfo.FullName); return false; } var invalidAttributes = new Type[] { typeof(SetUpAttribute), typeof(TearDownAttribute), #pragma warning disable 618 // Obsolete Attributes typeof(TestFixtureSetUpAttribute), typeof(TestFixtureTearDownAttribute) }; #pragma warning restore foreach (Type invalidType in invalidAttributes) if (typeInfo.HasMethodWithAttribute(invalidType)) { reason = invalidType.Name + " attribute not allowed in a SetUpFixture"; return false; } return true; }
public override IEnumerable<Attribute> GetAttributes(ITypeInfo typesInfo) { if (typesInfo.Type != typeof(Analysis)) yield break; yield return new CloneViewAttribute(CloneViewType.DetailView, InPlaceEdit_DetailView); yield return new XpandNavigationItemAttribute("PivotChart/In Place Edit", InPlaceEdit_DetailView) { ObjectKey = "Name='InPlaceEdit'" }; yield return new DisplayFeatureModelAttribute(InPlaceEdit_DetailView, new BinaryOperator("Name", "InPlaceEdit")); yield return new ActionStateRuleAttribute("Hide_save_and_close_for_" + InPlaceEdit_DetailView, "SaveAndClose", "1=1", "1=1", ActionState.Hidden); }
public IntPtr GetTypeAttr(ITypeInfo typeInfo) { if (typeInfo == null) throw new ArgumentNullException(nameof(typeInfo)); IntPtr ret; typeInfo.GetTypeAttr(out ret); return ret; }
public IntPtr GetVarDesc(ITypeInfo typeInfo, int index) { if (typeInfo == null) throw new ArgumentNullException(nameof(typeInfo)); IntPtr ret; typeInfo.GetVarDesc(index, out ret); return ret; }
internal ComMethodDesc(ITypeInfo typeInfo, FUNCDESC funcDesc) : this(funcDesc.memid) { _hasTypeInfo = true; InvokeKind = funcDesc.invkind; int cNames; string[] rgNames = new string[1 + funcDesc.cParams]; typeInfo.GetNames(_memid, rgNames, rgNames.Length, out cNames); if (IsPropertyPut && rgNames[rgNames.Length - 1] == null) { rgNames[rgNames.Length - 1] = "value"; cNames++; } Debug.Assert(cNames == rgNames.Length); _name = rgNames[0]; _parameters = new ComParamDesc[funcDesc.cParams]; int offset = 0; for (int i = 0; i < funcDesc.cParams; i++) { ELEMDESC elemDesc = (ELEMDESC)Marshal.PtrToStructure( new IntPtr(funcDesc.lprgelemdescParam.ToInt64() + offset), typeof(ELEMDESC)); _parameters[i] = new ComParamDesc(ref elemDesc, rgNames[1 + i]); offset += Marshal.SizeOf(typeof(ELEMDESC)); } }
public override IEnumerable<Attribute> GetAttributes(ITypeInfo typesInfo) { if (typesInfo.Type != typeof(Customer)) yield break; const string viewId = "Customer_DetailView"; yield return new XpandNavigationItemAttribute("Navigation/Detail View of Persistent object with records", viewId); yield return new AdditionalViewControlsRuleAttribute(Captions.ViewMessage + " " + Captions.HeaderDetailViewNavigation, "1=1", "1=1", Captions.ViewMessageDetailViewNavigation, Position.Bottom) { View = viewId }; yield return new AdditionalViewControlsRuleAttribute(Captions.Header + " " + Captions.HeaderDetailViewNavigation, "1=1", "1=1", Captions.HeaderDetailViewNavigation, Position.Top) { View = viewId }; }
public ConstructorBlock(IEmitter emitter, ITypeInfo typeInfo, bool staticBlock) : base(emitter, typeInfo.TypeDeclaration) { this.Emitter = emitter; this.TypeInfo = typeInfo; this.StaticBlock = staticBlock; }
public override IEnumerable<Attribute> GetAttributes(ITypeInfo typesInfo) { if (typesInfo.Type != typeof(Customer)) yield break; yield return new AdditionalViewControlsRuleAttribute(Captions.ViewMessage + " " + Captions.HeaderLinqQuery, "1=1", "1=1", Captions.ViewMessageLinqQuery, Position.Bottom) { ViewType = ViewType.ListView, View = "Customer_ListView_EmployeesLinq_Linq" }; yield return new AdditionalViewControlsRuleAttribute(Captions.Header + " " + Captions.HeaderLinqQuery, "1=1", "1=1", Captions.HeaderLinqQuery, Position.Top) { ViewType = ViewType.ListView, View = "Customer_ListView_EmployeesLinq_Linq" }; yield return new XpandNavigationItemAttribute(Captions.Miscellaneous + "LinqQuery", "Customer_ListView_EmployeesLinq_Linq"); yield return new CloneViewAttribute(CloneViewType.ListView, "LinqQuery_ListView"); }
public override IEnumerable<Attribute> GetAttributes(ITypeInfo typesInfo) { if (typesInfo.Type!=typeof(PersistentAssemblyInfo))yield break; yield return new CloneViewAttribute(CloneViewType.DetailView, "NorthWind_DetailView"); yield return new XpandNavigationItemAttribute("WorldCreator/NorthWind/NorthWind AssemblyInfo", "NorthWind_DetailView") { ObjectKey = CriteriaOperator.Parse("Name=?", "NorthWind").ToString() }; yield return new AdditionalViewControlsRuleAttribute(Captions.ViewMessage + " " + Captions.HeaderNorthWind, "1=1", "1=1", Captions.ViewMessageNorthWind, Position.Bottom) { View = "NorthWind_DetailView" }; yield return new AdditionalViewControlsRuleAttribute(Captions.Header + " " + Captions.HeaderNorthWind, "1=1", "1=1", Captions.HeaderNorthWind, Position.Top) { View = "NorthWind_DetailView" }; }
public VsixTestCollection (ITestAssembly testAssembly, ITypeInfo collectionDefinition, string visualStudioVersion, string rootSuffix) : base (testAssembly, collectionDefinition, visualStudioVersion + " (" + rootSuffix + ")") { VisualStudioVersion = visualStudioVersion; RootSuffix = rootSuffix; }
/// <summary> /// Initializes a new instance of the <see cref="XunitTestCollection"/> class. /// </summary> public XunitTestCollection(ITestAssembly testAssembly, ITypeInfo collectionDefinition, string displayName) { CollectionDefinition = collectionDefinition; DisplayName = displayName; TestAssembly = testAssembly; UniqueID = Guid.NewGuid(); }
public override IEnumerable<Attribute> GetAttributes(ITypeInfo typesInfo) { if (!(typesInfo.Type == typeof (PersistentAssemblyInfo))) yield break; yield return new CloneViewAttribute(CloneViewType.DetailView, Quartz_DetailView); yield return new XpandNavigationItemAttribute("WorldCreator/Quartz/Quartz AssemblyInfo", Quartz_DetailView) { ObjectKey = CriteriaOperator.Parse("Name=?", "Quartz").ToString() }; yield return new AdditionalViewControlsRuleAttribute(Captions.ViewMessage + " " + Captions.HeaderQuartz, "1=1", "1=1", Captions.ViewMessageQuartz, Position.Bottom) { View = Quartz_DetailView }; yield return new AdditionalViewControlsRuleAttribute(Captions.Header + " " + Captions.HeaderQuartz, "1=1", "1=1", Captions.HeaderQuartz, Position.Top) { View = Quartz_DetailView }; }
private MetadataMethodInfoAdapter2(MetadataTypeInfoAdapter2 typeInfo, IMetadataMethod method, ITypeInfo[] substitutions) { this.typeInfo = typeInfo; this.method = method; this.substitutions = substitutions; }
public void AfterTypeEmit(IEmitter emitter, ITypeInfo type) { foreach (var plugin in this.Parts) { plugin.AfterTypeEmit(emitter, type); } }
/// <summary> /// Creates the test class command, which implements <see cref="ITestClassCommand"/>, for a given type. /// </summary> /// <param name="typeInfo">The type under test</param> /// <returns>The test class command, if the class is a test class; null, otherwise</returns> public static ITestClassCommand Make(ITypeInfo typeInfo) { if (!TypeUtility.IsTestClass(typeInfo)) return null; ITestClassCommand command = null; if (TypeUtility.HasRunWith(typeInfo)) { ITypeInfo runWithTypeInfo = TypeUtility.GetRunWith(typeInfo); if (runWithTypeInfo == null) return null; Type runWithCommandType = runWithTypeInfo.Type; if (runWithCommandType != null) command = (ITestClassCommand)Activator.CreateInstance(runWithCommandType); } else if (TypeUtility.ContainsTestMethods(typeInfo)) command = new TestClassCommand(); if (command != null) command.TypeUnderTest = typeInfo; return command; }
public void Reset(IMethod method, ITypeInfo typeInfo) { this.method = method; var containingType = method.GetContainingType(); TypeName = containingType.GetClrName().FullName; Class = typeInfo ?? ((IClass) containingType).AsTypeInfo(); }
public StateMachineCollectionSource(IObjectSpace objectSpace, IStateMachineRepository repository, Type type) : base(objectSpace) { _objectSpace = objectSpace; _repository = repository; _type = type; objectTypeInfoCore = XafTypesInfo.Instance.FindTypeInfo(typeof(IStateMachine)); }
void Initialize(ITestCollection testCollection, IAssemblyInfo assembly, ITypeInfo type, IMethodInfo method, IAttributeInfo factAttribute, object[] arguments) { string displayNameBase = factAttribute.GetNamedArgument<string>("DisplayName") ?? type.Name + "." + method.Name; ITypeInfo[] resolvedTypes = null; if (arguments != null && method.IsGenericMethodDefinition) { resolvedTypes = ResolveGenericTypes(method, arguments); method = method.MakeGenericMethod(resolvedTypes); } Assembly = assembly; Class = type; Method = method; Arguments = arguments; DisplayName = GetDisplayNameWithArguments(displayNameBase, arguments, resolvedTypes); SkipReason = factAttribute.GetNamedArgument<string>("Skip"); Traits = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase); TestCollection = testCollection; foreach (IAttributeInfo traitAttribute in Method.GetCustomAttributes(typeof(TraitAttribute)) .Concat(Class.GetCustomAttributes(typeof(TraitAttribute)))) { var ctorArgs = traitAttribute.GetConstructorArguments().ToList(); Traits.Add((string)ctorArgs[0], (string)ctorArgs[1]); } uniqueID = new Lazy<string>(GetUniqueID, true); }
/// <summary> /// Gets the default value for a reflected type. /// </summary> /// <param name="type">The reflected type.</param> /// <returns>The default value for the type, such as <c>0</c> if /// the type represents an integer, or <c>null</c> if the type /// is a reference type or if <paramref name="type"/> was null.</returns> public static object GetDefaultValue(ITypeInfo type) { if (type == null) return null; return ReflectionUtils.GetDefaultValue(type.TypeCode); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedType" /> class. /// </summary> /// <param name="info">The type information.</param> /// <param name="properties">The type's properties.</param> /// <param name="methods">The type's methods.</param> /// <param name="fields">The type's fields.</param> /// <param name="summary">The summary.</param> /// <param name="remarks">The remarks.</param> /// <param name="examples">The examples.</param> /// <param name="metadata">The type metadata.</param> public DocumentedType( ITypeInfo info, IEnumerable<DocumentedProperty> properties, IEnumerable<DocumentedMethod> methods, IEnumerable<DocumentedField> fields, SummaryComment summary, RemarksComment remarks, IEnumerable<ExampleComment> examples, IDocumentationMetadata metadata) : base(MemberClassification.Type, summary, remarks, examples, metadata) { Definition = info.Definition; TypeClassification = info.Definition.GetTypeClassification(); Identity = info.Identity; Properties = new List<DocumentedProperty>(properties); Fields = new List<DocumentedField>(fields); // Materialize all methods. var documentedMethods = methods as DocumentedMethod[] ?? methods.ToArray(); Constructors = new List<DocumentedMethod>(GetConstructors(documentedMethods)); Methods = new List<DocumentedMethod>(GetMethods(documentedMethods)); Operators = new List<DocumentedMethod>(GetOperators(documentedMethods)); _extensionMethods = new List<DocumentedMethod>(); }
public ViewInfo(string viewId, bool isDetailView, bool isRoot, ITypeInfo objectTypeInfo, ViewEditMode? viewEditMode) { ViewId = viewId; IsDetailView = isDetailView; IsRoot = isRoot; ObjectTypeInfo = objectTypeInfo; ViewEditMode = viewEditMode; }
/// <summary> /// Initializes a new instance of the <see cref="TestFixture"/> class. /// </summary> /// <param name="fixtureType">Type of the fixture.</param> public TestFixture(ITypeInfo fixtureType) : base(fixtureType) { CheckSetUpTearDownMethods(typeof(OneTimeSetUpAttribute)); CheckSetUpTearDownMethods(typeof(OneTimeTearDownAttribute)); CheckSetUpTearDownMethods(typeof(SetUpAttribute)); CheckSetUpTearDownMethods(typeof(TearDownAttribute)); }
public override IEnumerable<Attribute> GetAttributes(ITypeInfo typesInfo) { if (typesInfo.Type != typeof(ExceptionHandlingObject)) yield break; yield return new AdditionalViewControlsRuleAttribute(Captions.ViewMessage + " " + Captions.HeaderExceptionHandling, "1=1", "1=1", Captions.ViewMessageExceptionHandling, Position.Bottom) { ViewType = ViewType.DetailView, View = "ExceptionHandling_DetailView" }; yield return new AdditionalViewControlsRuleAttribute(Captions.Header + " " + Captions.HeaderExceptionHandling, "1=1", "1=1", Captions.HeaderExceptionHandling, Position.Top) { View = "ExceptionHandling_DetailView" }; yield return new CloneViewAttribute(CloneViewType.DetailView, "ExceptionHandling_DetailView"); yield return new XpandNavigationItemAttribute(Captions.Miscellaneous + "ExceptionHandling", "ExceptionHandling_DetailView"); }
/// <inheritdoc /> protected override PatternTest CreateTest(PatternEvaluationScope constainingScope, ITypeInfo type) { PatternTest test = base.CreateTest(constainingScope, type); test.Name = NameSanitizer.MakeNameFromIdentifier(test.Name); test.Kind = NBehaveTestKinds.Concern; return test; }
public CulturedXunitTestCase(ITestCollection testCollection, IAssemblyInfo assembly, ITypeInfo type, IMethodInfo method, IAttributeInfo factAttribute, string culture) : base(testCollection, assembly, type, method, factAttribute) { this.culture = culture; Traits.Add("Culture", culture); }
public ExcelImportWizard(ObjectSpace objectSpace, ITypeInfo typeInfo, CollectionSourceBase collectionSourceBase) { //set local variable values if (objectSpace == null) throw new ArgumentNullException("objectSpace", @"ObjectSpace cannot be NULL"); ObjectSpace = objectSpace; CurrentCollectionSource = collectionSourceBase; //_ImportUOW = new UnitOfWork(((ObjectSpace)ObjectSpace).Session.DataLayer); Type = typeInfo.Type; //this.typeInfo = typeInfo; InitializeComponent(); ImportMapLookUp.Properties.DataSource = ImportMapsCollection.ToList(); //ImportMapLookUp.Properties.DisplayMember = "Name"; //disable next, until file and other info is selected wizardPage1.AllowNext = false; gridLookUpEdit1.Properties.View.OptionsBehavior.AutoPopulateColumns = true; gridLookUpEdit1.Properties.DataSource = MappableColumns;//.ToList(); // gridLookUpEdit1.Properties.SearchMode = SearchMode.OnlyInPopup; var col = gridLookUpEdit2View.Columns.ColumnByFieldName("Mapped"); if (col != null) { col.Visible = false; col.FilterInfo = new ColumnFilterInfo(new BinaryOperator("Mapped", false)); } col = gridLookUpEdit2View.Columns.ColumnByFieldName("Oid"); if (col != null) col.Visible = false; }
/// <summary> /// Initializes a new instance of the <see cref="ConcordionTypeInfoAdapter"/> class. /// </summary> /// <param name="target">The target.</param> public ConcordionTypeInfoAdapter(ITypeInfo target) { if (target == null) throw new ArgumentNullException("target"); Target = target; }
//Extra constructor to enable Value mapping customisation public ExcelImportWizard(XPObjectSpace objectSpace, ITypeInfo typeInfo, CollectionSourceBase collectionSourceBase, XafApplication application, StringValueMapper valueMapper) : this(objectSpace, typeInfo, collectionSourceBase, application, valueMapper.MapValueToObjectProperty) { }
public BuiltinTypeBuildingContext(ITypeInfo type) : base(type) { }
void AddItem(ChoiceActionItemCollection choiceActionItemCollection, List <string> strings, ITypeInfo groupedType) { string itemId = strings[0]; ChoiceActionItem choiceActionItem = choiceActionItemCollection.FindItemByID(itemId); if (choiceActionItem == null) { choiceActionItem = new ChoiceActionItem(itemId, itemId, null); choiceActionItemCollection.Add(choiceActionItem); strings.RemoveAt(0); if (strings.Count == 0) { AddItemCore(choiceActionItem, groupedType); return; } AddItem(choiceActionItem.Items, strings, groupedType); return; } strings.RemoveAt(0); if (strings.Count == 0) { AddItemCore(choiceActionItem, groupedType); return; } AddItem(choiceActionItem.Items, strings, groupedType); }
public override void VisitTypeDeclaration(TypeDeclaration typeDeclaration) { if (this.CurrentType != null) { this.NestedTypes = this.NestedTypes ?? new List <Tuple <TypeDeclaration, ITypeInfo> >(); this.NestedTypes.Add(new Tuple <TypeDeclaration, ITypeInfo>(typeDeclaration, this.CurrentType)); return; } ValidateNamespace(typeDeclaration); var rr = this.Resolver.ResolveNode(typeDeclaration, null); var fullName = rr.Type.ReflectionName; var partialType = this.Types.FirstOrDefault(t => t.Key == fullName); var add = true; var ignored = this.IgnoredTypes.Contains(fullName); var external = this.HasExternal(typeDeclaration); if (!external) { var resolveResult = this.Resolver.ResolveNode(typeDeclaration, null); if (resolveResult != null && resolveResult.Type != null) { var def = resolveResult.Type.GetDefinition(); external = def != null && def.ParentAssembly.AssemblyAttributes.Any(a => a.AttributeType.FullName == "Bridge.ExternalAttribute"); } } if ((external || ignored || this.IsNonScriptable(typeDeclaration)) && !this.IsObjectLiteral(typeDeclaration)) { if (partialType != null) { this.Types.Remove(partialType); } if (!ignored) { this.IgnoredTypes.Add(fullName); } return; } if (partialType == null) { ITypeInfo parentTypeInfo = null; var parentTypeDeclaration = typeDeclaration.GetParent <TypeDeclaration>(); if (parentTypeDeclaration != null) { var rr1 = this.Resolver.ResolveNode(parentTypeDeclaration, null); var parentName = rr1.Type.ReflectionName; parentTypeInfo = this.Types.FirstOrDefault(t => t.Key == parentName); } this.CurrentType = new TypeInfo() { Key = rr.Type.ReflectionName, TypeDeclaration = typeDeclaration, ParentType = parentTypeInfo, Name = typeDeclaration.Name, ClassType = typeDeclaration.ClassType, Namespace = this.Namespace, IsEnum = typeDeclaration.ClassType == ClassType.Enum, IsStatic = typeDeclaration.ClassType == ClassType.Enum || typeDeclaration.HasModifier(Modifiers.Static), IsObjectLiteral = this.IsObjectLiteral(typeDeclaration), Type = rr.Type }; } else { this.CurrentType = partialType; this.CurrentType.PartialTypeDeclarations.Add(typeDeclaration); add = false; } if (typeDeclaration.ClassType != ClassType.Interface) { typeDeclaration.AcceptChildren(this); } else { typeDeclaration.AcceptChildren(this); } if (add) { this.Types.Add(this.CurrentType); } if (typeDeclaration.ClassType != ClassType.Interface) { this.AddMissingAliases(typeDeclaration); } this.CurrentType = null; while (this.NestedTypes != null && this.NestedTypes.Count > 0) { var types = this.NestedTypes; this.NestedTypes = null; foreach (var nestedType in types) { this.VisitTypeDeclaration(nestedType.Item1); } } }
public string GetTypeLocation(ITypeInfo type) { return(type.Name); }
public TypeScriptTypeMemberDeclaration ResolveProperty(TypeScriptUnit unit, ITypeGenerator typeGenerator, ITypeInfo type, IPropertyInfo property) { return(null); }
public ITypeBuildingContext ResolveType(string initialUnitPath, ITypeGenerator typeGenerator, ITypeInfo type, ITypeScriptUnitFactory unitFactory) { return(null); }
public override bool IsAssignableFrom(ITypeInfo typeInfo) { return(this._type.IsAssignableFrom(((AbstractTypeInfo)typeInfo).Type)); }
public ConstructorBlock(IEmitter emitter, ITypeInfo typeInfo) : base(emitter, typeInfo.TypeDeclaration) { this.Emitter = emitter; this.TypeInfo = typeInfo; }
public override object[] GetCustomAttributes(ITypeInfo attributeType, bool inherit) { return(this._type.GetCustomAttributes(((TypeInfoWrapper)attributeType)._type, inherit)); }
//This overload should only be used for retrieving the TypeName from a random TYPEATTR. TODO: This really belongs somewhere else. public ComParameter(TYPEATTR attributes, ITypeInfo info) { GetParameterType(attributes.tdescAlias, info); }
public static Com2Properties GetProperties(object obj) { Debug.WriteLineIf(DbgTypeInfoProcessorSwitch.TraceVerbose, "Com2TypeInfoProcessor.GetProperties"); if (obj is null || !Marshal.IsComObject(obj)) { Debug.WriteLineIf(DbgTypeInfoProcessorSwitch.TraceVerbose, "Com2TypeInfoProcessor.GetProperties returning null: Object is not a com Object"); return(null); } ITypeInfo[] typeInfos = FindTypeInfos(obj, false); // oops, looks like this guy doesn't surface any type info // this is okay, so we just say it has no props if (typeInfos is null || typeInfos.Length == 0) { Debug.WriteLineIf(DbgTypeInfoProcessorSwitch.TraceVerbose, "Com2TypeInfoProcessor.GetProperties :: Didn't get typeinfo"); return(null); } int defaultProp = -1; int temp = -1; ArrayList propList = new ArrayList(); Guid[] typeGuids = new Guid[typeInfos.Length]; for (int i = 0; i < typeInfos.Length; i++) { ITypeInfo ti = typeInfos[i]; if (ti is null) { continue; } uint[] versions = new uint[2]; Guid typeGuid = GetGuidForTypeInfo(ti, versions); PropertyDescriptor[] props = null; bool dontProcess = typeGuid != Guid.Empty && processedLibraries is not null && processedLibraries.Contains(typeGuid); if (dontProcess) { CachedProperties cp = (CachedProperties)processedLibraries[typeGuid]; if (versions[0] == cp.MajorVersion && versions[1] == cp.MinorVersion) { props = cp.Properties; if (i == 0 && cp.DefaultIndex != -1) { defaultProp = cp.DefaultIndex; } } else { dontProcess = false; } } if (!dontProcess) { props = InternalGetProperties(obj, ti, DispatchID.MEMBERID_NIL, ref temp); // only save the default property from the first type Info if (i == 0 && temp != -1) { defaultProp = temp; } if (processedLibraries is null) { processedLibraries = new Hashtable(); } if (typeGuid != Guid.Empty) { processedLibraries[typeGuid] = new CachedProperties(props, i == 0 ? defaultProp : -1, versions[0], versions[1]); } } if (props is not null) { propList.AddRange(props); } } Debug.WriteLineIf(DbgTypeInfoProcessorSwitch.TraceVerbose, "Com2TypeInfoProcessor.GetProperties : returning " + propList.Count.ToString(CultureInfo.InvariantCulture) + " properties"); // done! Com2PropertyDescriptor[] temp2 = new Com2PropertyDescriptor[propList.Count]; propList.CopyTo(temp2, 0); return(new Com2Properties(obj, temp2, defaultProp)); }
/// <inheritdoc/> protected override ITestClass CreateTestClass(ITypeInfo @class) { return(new TestClass(TestCollectionFactory.Get(@class), @class)); }
private void GetParameterType(TYPEDESC desc, ITypeInfo info) { var vt = (VarEnum)desc.vt; TYPEDESC tdesc; if (vt == VarEnum.VT_PTR) { tdesc = Marshal.PtrToStructure <TYPEDESC>(desc.lpValue); GetParameterType(tdesc, info); IsByRef = true; } else if (vt == VarEnum.VT_USERDEFINED) { int href; unchecked { href = (int)(desc.lpValue.ToInt64() & 0xFFFFFFFF); } try { info.GetRefTypeInfo(href, out ITypeInfo refTypeInfo); refTypeInfo.GetTypeAttr(out IntPtr attribPtr); using (DisposalActionContainer.Create(attribPtr, refTypeInfo.ReleaseTypeAttr)) { var attribs = Marshal.PtrToStructure <TYPEATTR>(attribPtr); var type = new ComDocumentation(refTypeInfo, ComDocumentation.LibraryIndex).Name; if (attribs.typekind == TYPEKIND.TKIND_ENUM) { _typeName = new ComTypeName(Project, type, attribs.guid, Guid.Empty); } else if (attribs.typekind == TYPEKIND.TKIND_ALIAS) { _typeName = new ComTypeName(Project, type, Guid.Empty, attribs.guid); } else { _typeName = new ComTypeName(Project, type); } } } catch (COMException) { _typeName = new ComTypeName(Project, Tokens.Object); } } else if (vt == VarEnum.VT_SAFEARRAY || vt == VarEnum.VT_CARRAY || vt.HasFlag(VarEnum.VT_ARRAY)) { tdesc = Marshal.PtrToStructure <TYPEDESC>(desc.lpValue); GetParameterType(tdesc, info); IsArray = true; } else if (vt == VarEnum.VT_HRESULT) { _typeName = new ComTypeName(Project, Tokens.Long); } else { _typeName = new ComTypeName(Project, (ComVariant.TypeNames.TryGetValue(vt, out string result)) ? result : Tokens.Object); } }
static IEnumerable <ILogicRule> GetLogicRuleAttributes(ITypeInfo typeInfo) { return(typeInfo.FindAttributes <Attribute>(false).OfType <ILogicRule>()); }
public GenericParameterTypeBuildingContext(ITypeInfo type) { this.type = type; }
public static bool HasRules <TLogicInstaller>(ITypeInfo typeInfo) where TLogicInstaller : ILogicInstaller { return(LogicInstallerManager.Instance.LogicInstallers.OfType <TLogicInstaller>().First().ValidExecutionContexts.Any(context => Instance[new Tuple <ITypeInfo, ExecutionContext>(typeInfo, context)].Any())); }
private static string GetStringFromTypeDesc(ITypeInfo typeinfo, System.Runtime.InteropServices.ComTypes.TYPEDESC typedesc) { if (typedesc.vt == (short)26) { System.Runtime.InteropServices.ComTypes.TYPEDESC structure = (System.Runtime.InteropServices.ComTypes.TYPEDESC)Marshal.PtrToStructure(typedesc.lpValue, typeof(System.Runtime.InteropServices.ComTypes.TYPEDESC)); return(ComUtil.GetStringFromTypeDesc(typeinfo, structure)); } if (typedesc.vt == (short)27) { System.Runtime.InteropServices.ComTypes.TYPEDESC structure = (System.Runtime.InteropServices.ComTypes.TYPEDESC)Marshal.PtrToStructure(typedesc.lpValue, typeof(System.Runtime.InteropServices.ComTypes.TYPEDESC)); return("SAFEARRAY(" + ComUtil.GetStringFromTypeDesc(typeinfo, structure) + ")"); } if (typedesc.vt == (short)29) { return(ComUtil.GetStringFromCustomType(typeinfo, typedesc.lpValue)); } switch ((VarEnum)typedesc.vt) { case VarEnum.VT_EMPTY: return(""); case VarEnum.VT_I2: return("short"); case VarEnum.VT_I4: case VarEnum.VT_INT: case VarEnum.VT_HRESULT: return("int"); case VarEnum.VT_R4: return("float"); case VarEnum.VT_R8: return("double"); case VarEnum.VT_CY: return("currency"); case VarEnum.VT_DATE: return("Date"); case VarEnum.VT_BSTR: case VarEnum.VT_LPSTR: case VarEnum.VT_LPWSTR: return("string"); case VarEnum.VT_DISPATCH: return("IDispatch"); case VarEnum.VT_BOOL: return("bool"); case VarEnum.VT_VARIANT: return("Variant"); case VarEnum.VT_UNKNOWN: return("IUnknown"); case VarEnum.VT_DECIMAL: return("decimal"); case VarEnum.VT_I1: return("char"); case VarEnum.VT_UI1: return("byte"); case VarEnum.VT_UI2: return("ushort"); case VarEnum.VT_UI4: case VarEnum.VT_UINT: return("uint"); case VarEnum.VT_I8: return("int64"); case VarEnum.VT_UI8: return("uint64"); case VarEnum.VT_VOID: return("void"); case VarEnum.VT_CLSID: return("clsid"); case VarEnum.VT_ARRAY: return("object[]"); default: return("Unknown!"); } }
private static void PopulateConfigFromType(ItemStorageConfig config, ITypeInfo typeInfo) { DynamoDBTableAttribute tableAttribute = Utils.GetTableAttribute(typeInfo); if (tableAttribute == null) { config.TableName = typeInfo.Name; } else { if (string.IsNullOrEmpty(tableAttribute.TableName)) { throw new InvalidOperationException("DynamoDBTableAttribute.Table is empty or null"); } config.TableName = tableAttribute.TableName; config.LowerCamelCaseProperties = tableAttribute.LowerCamelCaseProperties; } string tableAlias; if (AWSConfigsDynamoDB.Context.TableAliases.TryGetValue(config.TableName, out tableAlias)) { config.TableName = tableAlias; } foreach (var member in typeInfo.GetMembers()) { if (!StorageConfig.IsValidMemberInfo(member)) { continue; } // prepare basic info PropertyStorage propertyStorage = new PropertyStorage(member); propertyStorage.AttributeName = GetAccurateCase(config, member.Name); // run through all DDB attributes List <DynamoDBAttribute> allAttributes = Utils.GetAttributes(member); foreach (var attribute in allAttributes) { // filter out ignored properties if (attribute is DynamoDBIgnoreAttribute) { propertyStorage.IsIgnored = true; } if (attribute is DynamoDBVersionAttribute) { propertyStorage.IsVersion = true; } DynamoDBPropertyAttribute propertyAttribute = attribute as DynamoDBPropertyAttribute; if (propertyAttribute != null) { if (!string.IsNullOrEmpty(propertyAttribute.AttributeName)) { propertyStorage.AttributeName = GetAccurateCase(config, propertyAttribute.AttributeName); } if (propertyAttribute.Converter != null) { propertyStorage.ConverterType = propertyAttribute.Converter; } if (propertyAttribute is DynamoDBHashKeyAttribute) { var gsiHashAttribute = propertyAttribute as DynamoDBGlobalSecondaryIndexHashKeyAttribute; if (gsiHashAttribute != null) { propertyStorage.IsGSIHashKey = true; propertyStorage.AddIndex(gsiHashAttribute); } else { propertyStorage.IsHashKey = true; } } if (propertyAttribute is DynamoDBRangeKeyAttribute) { var gsiRangeAttribute = propertyAttribute as DynamoDBGlobalSecondaryIndexRangeKeyAttribute; if (gsiRangeAttribute != null) { propertyStorage.IsGSIRangeKey = true; propertyStorage.AddIndex(gsiRangeAttribute); } else { propertyStorage.IsRangeKey = true; } } DynamoDBLocalSecondaryIndexRangeKeyAttribute lsiRangeKeyAttribute = propertyAttribute as DynamoDBLocalSecondaryIndexRangeKeyAttribute; if (lsiRangeKeyAttribute != null) { propertyStorage.IsLSIRangeKey = true; propertyStorage.AddIndex(lsiRangeKeyAttribute); } } } config.Properties.Add(propertyStorage); } }
public static IEnumerable <ILogicRule> FindAttributes(ITypeInfo typeInfo) { return(typeInfo != null?GetLogicRuleAttributes(typeInfo) : null); }
private void SetValues() { Edit.Items.List.Clear(); IList <TagSourceAttribute> tagSources = MemberInfo.FindAttributes <TagSourceAttribute>().ToList(); IMemberInfo info; #region Set values from tag sources foreach (var tagSource in tagSources) { switch (tagSource.Kind) { case TagSourceKind.TypeSource: if (typeof(Enum).IsAssignableFrom(tagSource.Type)) { IList <String> Names = Enum.GetNames(tagSource.Type); Array Values = Enum.GetValues(tagSource.Type); String format = String.Concat(tagSource.ValueFormat); if (format == "") { format = "{0}"; } for (int i = 0; i < Names.Count; i++) { String imageName = Helpers.GetXafImageName((Enum)Values.GetValue(i)); if (Edit.Items.List.Where(f => f.Text == String.Format(format, Names[i])).Count() == 0) { var item = Edit.Items.Add(); item.Text = String.Format(format, Names[i]); item.Value = String.Concat(Values.GetValue(i)); if (imageName == "") { imageName = String.Concat(tagSource.ImageName); } } } } else { IObjectSpace os = (WebApplication.Instance as XafApplication).CreateObjectSpace(tagSource.Type); CollectionSource cs = new CollectionSource(os, tagSource.Type); if (tagSource.Criteria != null) { cs.Criteria["Criteria"] = PrepareCriteria(tagSource.Criteria); } String format = String.Concat(tagSource.ValueFormat); if (format == "") { ITypeInfo TypeInfo = XafTypesInfo.Instance.FindTypeInfo(tagSource.Type); if (TypeInfo != null) { ObjectCaptionFormatAttribute attr = TypeInfo.FindAttribute <ObjectCaptionFormatAttribute>(); if (attr != null) { format = attr.FormatString; } else { var defPropAttr = TypeInfo.FindAttribute <XafDefaultPropertyAttribute>(); if (defPropAttr != null) { format = "{0:" + defPropAttr.Name + "}"; } } } } IList list = null; switch (String.Concat(tagSource.Sorting).ToLower()) { case "asc": case "ascending": list = cs.List.OfType <object>().OrderBy(f => String.Format(new ObjectFormatter(), format, f)).ToList(); break; case "desc": case "descending": list = cs.List.OfType <object>().OrderByDescending(f => String.Format(new ObjectFormatter(), format, f)).ToList(); break; default: list = cs.List; break; } foreach (object obj in list) { var text = String.Format(new ObjectFormatter(), format, obj); if (Edit.Items.List.Where(f => f.Text == text).Count() == 0) { var item = Edit.Items.Add(); item.Text = String.Format(new ObjectFormatter(), format, obj); item.Value = String.Concat(ObjectFormatValues.GetValueRecursive(tagSource.Key, obj, out info)); } } } break; case TagSourceKind.Values: String Items = ""; try { Boolean IsProperty = false; var property = ObjectFormatValues.GetValueRecursive(tagSource.CommaValues, CurrentObject, out info); IObjectSpace os = (WebApplication.Instance as XafApplication).CreateObjectSpace(CurrentObject.GetType()); if (property is IEnumerable) { var coll = (property as IEnumerable); var format = ""; if (info.MemberTypeInfo != null) { var attr = info.MemberTypeInfo.FindAttribute <ObjectCaptionFormatAttribute>(); if (attr != null) { format = attr.FormatString; } else { var defPropAttr = info.MemberTypeInfo.FindAttribute <XafDefaultPropertyAttribute>(); if (defPropAttr != null) { format = "{0:" + defPropAttr.Name + "}"; } } } Items = String.Join(",", coll.OfType <object>().Select(f => String.Format("{0}|{1}" , (format == "" ? f : String.Format(new ObjectFormatter(), format, f)) , ObjectFormatValues.GetValueRecursive(os.GetKeyPropertyName(f.GetType()), f, out info)))); IsProperty = true; } else { Items = String.Concat(property); } if (!IsProperty) { Items = tagSource.CommaValues; } } catch (Exception ex) { Items = tagSource.CommaValues; } foreach (var item in Items.Split(',').Where(f => String.Concat(f) != "")) { if (Edit.Items.List.Where(f => f.Text == item.Split('|')[0]).Count() == 0) { var tagItem = Edit.Items.Add(); tagItem.Text = item.Split('|')[0]; if (item.Split('|').Count() > 1) { tagItem.Value = item.Split('|')[1]; } String imageName = tagSource.ImageName; if (item.Split('|').Count() > 2) { imageName = item.Split('|')[2]; } if (imageName != "") { tagItem.ImageUrl = DevExpress.ExpressApp.Utils.ImageLoader.Instance.GetImageInfo(tagSource.ImageName).ImageUrl; } } } break; } } #endregion }
public static bool HasRules(ITypeInfo typeInfo) { var executionContexts = LogicInstallerManager.Instance.LogicInstallers.SelectMany(installer => installer.ValidExecutionContexts); return(executionContexts.Any(context => Instance[new Tuple <ITypeInfo, ExecutionContext>(typeInfo, context)].Any())); }
protected virtual StringBuilder GetOutputForType(ITypeInfo typeInfo, string name, bool isMeta = false) { Module module = null; if (typeInfo != null && typeInfo.Module != null) { module = typeInfo.Module; } else if (this.Emitter.AssemblyInfo.Module != null) { module = this.Emitter.AssemblyInfo.Module; } var fileName = typeInfo != null ? typeInfo.FileName : name; if (fileName.IsEmpty() && this.Emitter.AssemblyInfo.OutputBy != OutputBy.Project) { switch (this.Emitter.AssemblyInfo.OutputBy) { case OutputBy.ClassPath: fileName = typeInfo.Type.FullName; break; case OutputBy.Class: fileName = this.GetIteractiveClassPath(typeInfo); break; case OutputBy.Module: fileName = module != null ? module.Name : null; break; case OutputBy.NamespacePath: case OutputBy.Namespace: fileName = typeInfo.GetNamespace(this.Emitter); break; default: break; } var isPathRelated = this.Emitter.AssemblyInfo.OutputBy == OutputBy.ClassPath || this.Emitter.AssemblyInfo.OutputBy == OutputBy.NamespacePath; if (fileName.IsNotEmpty() && isPathRelated) { fileName = fileName.Replace('.', System.IO.Path.DirectorySeparatorChar); if (this.Emitter.AssemblyInfo.StartIndexInName > 0) { fileName = fileName.Substring(this.Emitter.AssemblyInfo.StartIndexInName); } } } if (fileName.IsEmpty() && this.Emitter.AssemblyInfo.FileName != null) { fileName = this.Emitter.AssemblyInfo.FileName; } if (fileName.IsEmpty() && this.Emitter.Translator.ProjectProperties.AssemblyName != null) { fileName = this.Emitter.Translator.ProjectProperties.AssemblyName; } if (fileName.IsEmpty()) { fileName = AssemblyInfo.DEFAULT_FILENAME; } // Apply lowerCamelCase to filename if set up in bridge.json (or left default) if (this.Emitter.AssemblyInfo.FileNameCasing == FileNameCaseConvert.CamelCase) { var sepList = new string[] { ".", System.IO.Path.DirectorySeparatorChar.ToString(), "\\", "/" }; // Populate list only with needed separators, as usually we will never have all four of them var neededSepList = new List <string>(); foreach (var separator in sepList) { if (fileName.Contains(separator.ToString()) && !neededSepList.Contains(separator)) { neededSepList.Add(separator); } } // now, separating the filename string only by the used separators, apply lowerCamelCase if (neededSepList.Count > 0) { foreach (var separator in neededSepList) { var stringList = new List <string>(); foreach (var str in fileName.Split(separator[0])) { stringList.Add(str.ToLowerCamelCase()); } fileName = stringList.Join(separator); } } else { fileName = fileName.ToLowerCamelCase(); } } // Append '.js' extension to file name at translator.Outputs level: this aids in code grouping on files // when filesystem is not case sensitive. if (!FileHelper.IsJS(fileName)) { fileName += Contract.Constants.Files.Extensions.JS; } switch (this.Emitter.AssemblyInfo.FileNameCasing) { case FileNameCaseConvert.Lowercase: fileName = fileName.ToLower(); break; default: var lcFileName = fileName.ToLower(); // Find a file name that matches (case-insensitive) and use it as file name (if found) // The used file name will use the same casing of the existing one. foreach (var existingFile in this.Emitter.Outputs.Keys) { if (lcFileName == existingFile.ToLower()) { fileName = existingFile; } } break; } IEmitterOutput output = null; if (this.Emitter.Outputs.ContainsKey(fileName)) { output = this.Emitter.Outputs[fileName]; } else { output = new EmitterOutput(fileName) { IsMetadata = isMeta }; this.Emitter.Outputs.Add(fileName, output); } this.Emitter.EmitterOutput = output; if (module == null) { if (output.NonModuleDependencies == null) { output.NonModuleDependencies = new List <IPluginDependency>(); } this.Emitter.CurrentDependencies = output.NonModuleDependencies; return(output.NonModuletOutput); } if (module.Name == "") { module.Name = Bridge.Translator.AssemblyInfo.DEFAULT_FILENAME; } if (output.ModuleOutput.ContainsKey(module)) { this.Emitter.CurrentDependencies = output.ModuleDependencies[module.Name]; return(output.ModuleOutput[module]); } StringBuilder moduleOutput = new StringBuilder(); output.ModuleOutput.Add(module, moduleOutput); var dependencies = new List <IPluginDependency>(); output.ModuleDependencies.Add(module.Name, dependencies); if (typeInfo != null && typeInfo.Dependencies.Count > 0) { dependencies.AddRange(typeInfo.Dependencies); } this.Emitter.CurrentDependencies = dependencies; return(moduleOutput); }
public WebViewHtmlStringEditorDemoModelBuilder(ITypeInfo typeInfo) : base(typeInfo) { }
public static IAttributeInfo[] GetAttributes(this IAttributeProvider attributeProvider, ITypeInfo attributeType) { return(attributeProvider.GetAttributes(true).Where(x => x.AttributeType.Equals(attributeType)).ToArray()); }
public override string GetSkipReason(ITestMethod testMethod) { // A null or empty list of conditions is treated as "no conditions", // and the test cases will not be skipped. // Example: [Condition()] or [Condition((string[]) null)] int conditionCount = Conditions == null ? 0 : Conditions.Length; if (conditionCount == 0) { return(null); } MethodInfo testMethodInfo = testMethod.Method.ToRuntimeMethod(); Type testMethodDeclaringType = testMethodInfo.DeclaringType; List <string> falseConditions = new List <string>(conditionCount); foreach (string entry in Conditions) { string conditionMemberName = entry; // Null condition member names are silently tolerated if (string.IsNullOrWhiteSpace(conditionMemberName)) { continue; } string[] symbols = conditionMemberName.Split('.'); Type declaringType = testMethodDeclaringType; if (symbols.Length == 2) { conditionMemberName = symbols[1]; ITypeInfo type = testMethod.TestClass.Class.Assembly.GetTypes(false).Where(t => t.Name.Contains(symbols[0])).SingleOrDefault(); if (type != null) { declaringType = type.ToRuntimeType(); } } MethodInfo conditionMethodInfo; if ((conditionMethodInfo = LookupConditionalMethod(declaringType, conditionMemberName)) == null) { falseConditions.Add(String.Format("Condition \"{0}\" not found in type \"{1}\".", conditionMemberName, testMethodDeclaringType.FullName)); continue; } // In the case of multiple conditions, collect the results of all // of them to produce a summary skip reason. try { if (!(bool)conditionMethodInfo.Invoke(null, null)) { falseConditions.Add(conditionMemberName); } } catch (Exception exc) { falseConditions.Add(String.Format("Condition \"{0}\" threw exception {1}: \"{2}\".", conditionMemberName, exc.GetType().Name, exc.Message)); } } if (falseConditions.Count == 0) { return(null); } return(String.Format("{0}", String.Join(", ", falseConditions))); }
public static string GetTypeInfoName(ITypeInfo typeInfo) { throw new NotImplementedException(); }
/// <summary> /// Overload of BuildFrom called by tests that have arguments. /// Builds a fixture using the provided type and information /// in the ITestFixtureData object. /// </summary> /// <param name="typeInfo">The TypeInfo for which to construct a fixture.</param> /// <param name="testFixtureData">An object implementing ITestFixtureData or null.</param> /// <returns></returns> public TestSuite BuildFrom(ITypeInfo typeInfo, ITestFixtureData testFixtureData) { Guard.ArgumentNotNull(testFixtureData, "testFixtureData"); object[] arguments = testFixtureData.Arguments; if (typeInfo.ContainsGenericParameters) { Type[] typeArgs = testFixtureData.TypeArgs; if (typeArgs.Length == 0) { int cnt = 0; foreach (object o in arguments) { if (o is Type) { cnt++; } else { break; } } typeArgs = new Type[cnt]; for (int i = 0; i < cnt; i++) { typeArgs[i] = (Type)arguments[i]; } if (cnt > 0) { object[] args = new object[arguments.Length - cnt]; for (int i = 0; i < args.Length; i++) { args[i] = arguments[cnt + i]; } arguments = args; } } if (typeArgs.Length > 0 || TypeHelper.CanDeduceTypeArgsFromArgs(typeInfo.Type, arguments, ref typeArgs)) { typeInfo = typeInfo.MakeGenericType(typeArgs); } } var fixture = new TestFixture(typeInfo, arguments); if (arguments != null && arguments.Length > 0) { string name = fixture.Name = typeInfo.GetDisplayName(arguments); string nspace = typeInfo.Namespace; fixture.FullName = nspace != null && nspace != "" ? nspace + "." + name : name; } if (fixture.RunState != RunState.NotRunnable) { fixture.RunState = testFixtureData.RunState; } foreach (string key in testFixtureData.Properties.Keys) { foreach (object val in testFixtureData.Properties[key]) { fixture.Properties.Add(key, val); } } if (fixture.RunState != RunState.NotRunnable) { CheckTestFixtureIsValid(fixture); } fixture.ApplyAttributesToTest(typeInfo.Type.GetTypeInfo()); AddTestCasesToFixture(fixture); return(fixture); }
public IEnumerable <TestSuite> BuildFrom(ITypeInfo typeInfo) { return(BuildFrom(typeInfo, this)); }
/// <summary> /// Helper method that checks the signature of a TestMethod and /// any supplied parameters to determine if the test is valid. /// /// Currently, NUnitTestMethods are required to be public, /// non-abstract methods, either static or instance, /// returning void. They may take arguments but the _values must /// be provided or the TestMethod is not considered runnable. /// /// Methods not meeting these criteria will be marked as /// non-runnable and the method will return false in that case. /// </summary> /// <param name="testMethod">The TestMethod to be checked. If it /// is found to be non-runnable, it will be modified.</param> /// <param name="parms">Parameters to be used for this test, or null</param> /// <returns>True if the method signature is valid, false if not</returns> /// <remarks> /// The return value is no longer used internally, but is retained /// for testing purposes. /// </remarks> private static bool CheckTestMethodSignature(TestMethod testMethod, TestCaseParameters parms) { if (testMethod.Method.IsAbstract) { return(MarkAsNotRunnable(testMethod, "Method is abstract")); } if (!testMethod.Method.IsPublic) { return(MarkAsNotRunnable(testMethod, "Method is not public")); } IParameterInfo[] parameters; #if NETCF if (testMethod.Method.IsGenericMethodDefinition) { if (parms != null && parms.Arguments != null) { var mi = testMethod.Method.MakeGenericMethodEx(parms.Arguments); if (mi == null) { return(MarkAsNotRunnable(testMethod, "Cannot determine generic types by probing")); } testMethod.Method = mi; parameters = testMethod.Method.GetParameters(); } else { parameters = new IParameterInfo[0]; } } else { parameters = testMethod.Method.GetParameters(); } int minArgsNeeded = parameters.Length; #else parameters = testMethod.Method.GetParameters(); int minArgsNeeded = 0; foreach (var parameter in parameters) { // IsOptional is supported since .NET 1.1 if (!parameter.IsOptional) { minArgsNeeded++; } } #endif int maxArgsNeeded = parameters.Length; object[] arglist = null; int argsProvided = 0; if (parms != null) { testMethod.parms = parms; testMethod.RunState = parms.RunState; arglist = parms.Arguments; if (arglist != null) { argsProvided = arglist.Length; } if (testMethod.RunState != RunState.Runnable) { return(false); } } #if NETCF ITypeInfo returnType = testMethod.Method.IsGenericMethodDefinition && (parms == null || parms.Arguments == null) ? new TypeWrapper(typeof(void)) : testMethod.Method.ReturnType; #else ITypeInfo returnType = testMethod.Method.ReturnType; #endif #if NET_4_0 || NET_4_5 || PORTABLE if (AsyncInvocationRegion.IsAsyncOperation(testMethod.Method.MethodInfo)) { if (returnType.IsType(typeof(void))) { return(MarkAsNotRunnable(testMethod, "Async test method must have non-void return type")); } var returnsGenericTask = returnType.IsGenericType && returnType.GetGenericTypeDefinition() == typeof(System.Threading.Tasks.Task <>); if (returnsGenericTask && (parms == null || !parms.HasExpectedResult)) { return(MarkAsNotRunnable(testMethod, "Async test method must have non-generic Task return type when no result is expected")); } if (!returnsGenericTask && parms != null && parms.HasExpectedResult) { return(MarkAsNotRunnable(testMethod, "Async test method must have Task<T> return type when a result is expected")); } } else #endif if (returnType.IsType(typeof(void))) { if (parms != null && parms.HasExpectedResult) { return(MarkAsNotRunnable(testMethod, "Method returning void cannot have an expected result")); } } else if (parms == null || !parms.HasExpectedResult) { return(MarkAsNotRunnable(testMethod, "Method has non-void return value, but no result is expected")); } if (argsProvided > 0 && maxArgsNeeded == 0) { return(MarkAsNotRunnable(testMethod, "Arguments provided for method not taking any")); } if (argsProvided == 0 && minArgsNeeded > 0) { return(MarkAsNotRunnable(testMethod, "No arguments were provided")); } if (argsProvided < minArgsNeeded) { return(MarkAsNotRunnable(testMethod, string.Format("Not enough arguments provided, provide at least {0} arguments.", minArgsNeeded))); } if (argsProvided > maxArgsNeeded) { return(MarkAsNotRunnable(testMethod, string.Format("Too many arguments provided, provide at most {0} arguments.", maxArgsNeeded))); } if (testMethod.Method.IsGenericMethodDefinition && arglist != null) { var typeArguments = new GenericMethodHelper(testMethod.Method.MethodInfo).GetTypeArguments(arglist); foreach (Type o in typeArguments) { if (o == null || o == TypeHelper.NonmatchingType) { return(MarkAsNotRunnable(testMethod, "Unable to determine type arguments for method")); } } testMethod.Method = testMethod.Method.MakeGenericMethod(typeArguments); parameters = testMethod.Method.GetParameters(); } if (arglist != null && parameters != null) { TypeHelper.ConvertArgumentList(arglist, parameters); } return(true); }