public CompositeMethodGenerationInfo GetCompositeMethodGenerationInfo(CompositeMethodModel model) { return(this._compositeMethodGenerationInfos[model]); }
protected virtual void ValidateFragmentMethod(CompositeValidationResult result, CompositeModel compositeModel, CompositeMethodModel compositeMethod, AbstractFragmentMethodModel methodModel) { if (compositeMethod == null) { result.InternalValidationErrors.Add(ValidationErrorFactory.NewInternalError("Composite method model may not be null.", compositeModel)); } if (methodModel != null) { var declType = methodModel.NativeInfo.DeclaringType; if (!declType #if WINDOWS_PHONE_APP .GetTypeInfo() #endif .IsClass) { result.StructureValidationErrors.Add(ValidationErrorFactory.NewStructureError("The declaring type of fragment method " + methodModel.NativeInfo + " must be a class, however " + declType + " is not a class.", compositeModel, compositeMethod)); } if (!methodModel.IsGeneric && (!methodModel.NativeInfo.IsVirtual || methodModel.NativeInfo.IsFinal)) { result.StructureValidationErrors.Add(ValidationErrorFactory.NewStructureError("The method " + methodModel.NativeInfo + " in " + declType + " is not virtual, however, all composite methods must be virtual.", compositeModel, methodModel)); } if (declType #if WINDOWS_PHONE_APP .GetTypeInfo() #endif .IsSealed) { result.StructureValidationErrors.Add(ValidationErrorFactory.NewStructureError("The type " + declType + " is sealed, however, all fragment types must be non-sealed.", compositeModel, methodModel)); } //if ( !declType.IsPublic && !declType.IsNestedPublic ) //{ // String msg = null; // if ( methodModel.NativeInfo.IsAssembly || methodModel.NativeInfo.IsFamilyOrAssembly ) // { // if ( !declType.Assembly.GetCustomAttributes( true ).OfType<InternalsVisibleToAttribute>().Any( attr => Qi4CSGeneratedAssemblyAttribute.ASSEMBLY_NAME.Equals( attr.AssemblyName ) ) ) // { // msg = "The type " + declType + " is marked as internal, however, the " + typeof( InternalsVisibleToAttribute ) + " with argument " + typeof( Qi4CSGeneratedAssemblyAttribute ) + ".ASSEMBLY_NAME is not applied to the assembly"; // } // } // else // { // msg = "The type " + declType + " is not visible to the generated assembly."; // } // if ( msg != null ) // { // result.AddStructureError( new StructureValidationErrorImpl( compositeModel, methodModel, msg ) ); // } //} var genName = Qi4CSGeneratedAssemblyAttribute.GetGeneratedAssemblyName(declType.GetAssembly()); if (!IsTypeVisible(declType, genName)) { result.StructureValidationErrors.Add(ValidationErrorFactory.NewStructureError("The type " + declType + " is not visible. Consider either making it public, or internal with combination of applying " + typeof(InternalsVisibleToAttribute) + " with argument " + typeof(Qi4CSGeneratedAssemblyAttribute) + ".ASSEMBLY_NAME to the assembly.", compositeModel, methodModel)); } } }
public void RegisterCompositeMethodGenerationInfo(CompositeMethodModel model, CompositeMethodGenerationInfo info) { this._compositeMethodGenerationInfos.TryAdd(model, info); }
/// <summary> /// Gets enumerable of all method models of the <see cref="CompositeMethodModel"/>, including itself. /// The other method models are concatenated values of properties <see cref="CompositeMethodModel.Concerns"/>, <see cref="CompositeMethodModel.SideEffects"/> and <see cref="CompositeMethodModel.Mixin"/>. /// </summary> /// <param name="cModel">The <see cref="CompositeMethodModel"/>.</param> /// <returns>The enumerable of all method models of the <paramref name="cModel"/>, including <paramref name="cModel"/> itself.</returns> /// <exception cref="NullReferenceException">If <paramref name="cModel"/> is <c>null</c>.</exception> public static IEnumerable <AbstractMemberInfoModel <System.Reflection.MethodBase> > GetAllMethodModels(this CompositeMethodModel cModel) { return(Enumerable.Repeat(cModel, 1).Concat(cModel.Concerns.Cast <AbstractMethodModel>()).Concat(cModel.SideEffects).Concat(Enumerable.Repeat(cModel.Mixin, 1))); }