public ThinMember(ThinType declaringType, string memberName, string returnType, MemberTypes memberType, IncludeStatus includeStatus, ITypeDefinitionMember memberNode, VisibilityOverride visibility) : this(declaringType, memberName, returnType, memberType, includeStatus, memberNode, visibility, SecurityTransparencyStatus.Transparent) { }
public TrimAssembly(string assemblyName, IncludeStatus status) { _name = assemblyName; _includeStatus = status; _types = new Dictionary <string, TypeElement>(); _typeForwarders = new Dictionary <string, TypeForwarderElement>(); }
internal CodeAssemblyElement(IncludeStatus includeStatus, string key) { m_types = new Dictionary <string, TypeElement>(); m_typeForwarders = new Dictionary <string, TypeForwarderElement>(); _includeStatus = includeStatus; _key = key; }
public TrimType(String typeName, IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus) { _typeName = typeName; _typeMembers = new Dictionary <string, MemberElement>(); _includeStatus = includeStatus; _visibilityOverride = visibilityOverride; _securityTransparencyStatus = securityTransparencyStatus; }
internal CodeTypeElement(IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus, string key) { m_members = new Dictionary <string, MemberElement>(); _includeStatus = includeStatus; _visibilityOverride = visibilityOverride; _securityTransparencyStatus = securityTransparencyStatus; _key = key; }
public CodeMemberElement(IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus, string key, string returnType, MemberTypes memberType, string name) { _includeStatus = includeStatus; _visibilityOverride = visibilityOverride; _securityTransparencyStatus = securityTransparencyStatus; _key = key; _returnType = returnType; _memberType = memberType; _name = name; }
public override MemberElement CreateMemberElement(TypeElement type, string memberName, string returnType, MemberTypes memberType, IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus) { // Identify the member by category (method/prop/field/event), name, and return type. These // strings are what matched by ModelSigFormatter string memberSig = memberType.ToString() + " : " + memberName; if (returnType != null) memberSig = memberSig + " : " + returnType; CodeMemberElement member = new CodeMemberElement(includeStatus, visibilityOverride, securityTransparencyStatus, memberSig, returnType, memberType, memberName); (type as CodeTypeElement).m_members.Add(memberSig, member); return member; }
public ThinMember(ThinType declaringType, ThinMember memberToCopy) { _declaringType = declaringType; _memberNode = memberToCopy._memberNode; _memberFullName = memberToCopy._memberFullName; _returnType = memberToCopy._returnType; _memberType = memberToCopy._memberType; _includeStatus = memberToCopy._includeStatus; _visibility = memberToCopy._visibility; _securityTransparencyStatus = memberToCopy._securityTransparencyStatus; CheckVisibility(); }
public TrimMember(TrimType declaringType, string memberName, string returnType, /*string paramListString, */ MemberTypes memberType, IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus) { _declaringType = declaringType; _memberName = memberName; _returnType = returnType; _memberType = memberType; _includeStatus = includeStatus; _securityTransparencyStatus = securityTransparencyStatus; //_paramListString = paramListString; //if (null == paramListString) // _paramQualifiedTypeNames = new List<string>(); //else // _paramQualifiedTypeNames = SplitParameterList(paramListString); _visibilityOverride = visibilityOverride; }
public ThinMember(ThinType declaringType, string memberName, string returnType, MemberTypes memberType, IncludeStatus includeStatus, ITypeDefinitionMember memberNode, VisibilityOverride visibility, SecurityTransparencyStatus securityTransparencyStatus) { _memberNode = memberNode; _declaringType = declaringType; _returnType = returnType; _memberType = memberType; _includeStatus = includeStatus; _visibility = visibility; _securityTransparencyStatus = securityTransparencyStatus; _memberFullName = memberName; CheckVisibility(); }
private void ImportWorker(IncludeStatus statusToImport, AddAssembly addAssembly, AddType addType, AddTypeForwarder addTypeForwarder, AddMember addMember) { foreach (ThinAssembly assembly in _thinModel.Assemblies.Values) { if (assembly.IncludeStatus == statusToImport) { addAssembly(assembly); } foreach (ThinTypeForwarder typeForwarder in assembly.TypeForwarders.Values) { if (typeForwarder.IncludeStatus == statusToImport) { // Assembly may not have already been added because they might not have the correct IncludedStatus. addAssembly(assembly); addTypeForwarder(typeForwarder); } } foreach (ThinType type in assembly.Types.Values) { if (type.IncludeStatus == statusToImport) { // Assembly may not have already been added because they might not have the correct IncludedStatus. addAssembly(assembly); addType(type); } foreach (ThinMember member in type.Members.Values) { if (member.IncludeStatus == statusToImport) { // Assembly and Type may not have already been added because they might not have the correct IncludedStatus. addAssembly(assembly); addType(type); addMember(member); } } } } }
public ThinMember(ThinType declaringType, ITypeDefinitionMember member, IncludeStatus includeStatus, VisibilityOverride visibility) { _declaringType = declaringType; _memberNode = member; _memberType = Util.TypeMemberType(member); _returnType = Util.GetConversionOperatorReturnType(member); _memberFullName = Util.GetMemberSignature(member, false); // Remove the trailing return type for conversion operators if (_returnType != null) { string suffix = " : " + _returnType; if (_memberFullName.EndsWith(suffix)) _memberFullName = _memberFullName.Substring(0, _memberFullName.Length - suffix.Length); } _includeStatus = includeStatus; _visibility = visibility; _securityTransparencyStatus = SecurityTransparencyStatus.Transparent; CheckVisibility(); }
// Special case: If closureStatus == ApiRoot this will automatically // convert it to ImplRoot for internal types // TODO: Visitor should set status instead of this. public ThinModel ExportModel(IncludeStatus closureStatus) { _closureStatus = closureStatus; int nApiTypes = 0; int nApiTypeForwarders = 0; int nApiMembers = 0; ThinModel thinModel = new ThinModel(_thinModel.Options); Dictionary<String, ThinAssembly> assemblies = new Dictionary<String, ThinAssembly>(_depot.AssembliesClosure.Count); Dictionary<INamedTypeDefinition, ThinType> types = new Dictionary<INamedTypeDefinition, ThinType>(_depot.TypesClosure.Count); foreach (IAssembly assembly in _depot.AssembliesClosure.Values) { ThinAssembly thinAsm = new ThinAssembly(_thinModel, assembly.Name.Value, GetIncludeStatus(assembly), assembly); thinModel.Assemblies.Add(thinAsm.Name, thinAsm); assemblies.Add(assembly.Name.Value, thinAsm); } foreach (INamedTypeDefinition type in _depot.TypesClosure.Values) { IAssembly asm = TypeHelper.GetDefiningUnit(type) as IAssembly; if (asm != null && assemblies.ContainsKey(asm.Name.Value)) { VisibilityOverride vis = VisibilityOverride.None; if (ShouldHideType(type)) vis = VisibilityOverride.Internal; if (closureStatus != IncludeStatus.ApiRoot) { if (TypeIsVisibleInApi(type)) { INamedTypeDefinition curType = type; while (curType != null && curType != Dummy.Type && // TODO: Remove dummy check? CanInclude(curType)) { if (WeHidThisType(curType)) throw new Exception("API closure error! Base type " + curType + " was hidden, but " + type + " is in the public API"); ITypeReference curTypeRef = TypeHelper.BaseClass(curType); curType = curTypeRef != null ? Util.CanonicalizeType(curTypeRef) : null; } } } ThinAssembly declaringAssembly = assemblies[asm.Name.Value]; ThinType thinType = new ThinType(declaringAssembly, Util.FullyQualifiedTypeNameFromType(type), GetIncludeStatus(type), type, vis); declaringAssembly.Types.Add(thinType.Name, thinType); types.Add(type, thinType); if (thinType.IncludeStatus == IncludeStatus.ApiClosure || thinType.IncludeStatus == IncludeStatus.ApiRoot || thinType.IncludeStatus == IncludeStatus.ApiFxInternal) { nApiTypes++; } } else { Console.Error.WriteLine("BclRewriter : warning BR5004 : couldn't find declaring module of type {0} in closure", type); } } foreach (IAliasForType typeForwarder in _depot.TypeForwardersClosure.Values) { // TODO: Why is this getting an immutable copy of the assembly? IAssembly asm = Util.GetDefiningAssembly(typeForwarder); if (asm != null && assemblies.ContainsKey(asm.Name.Value)) { ThinAssembly declaringAssembly = assemblies[asm.Name.Value]; ITypeReference aliasedType = typeForwarder.AliasedType; ThinTypeForwarder thinTypeForwarder = new ThinTypeForwarder(declaringAssembly, Util.GetDefiningAssembly(aliasedType).Name.Value, Util.GetTypeName(aliasedType), GetIncludeStatus(typeForwarder), typeForwarder); declaringAssembly.TypeForwarders.Add(thinTypeForwarder.Key, thinTypeForwarder); if (thinTypeForwarder.IncludeStatus == IncludeStatus.ApiClosure || thinTypeForwarder.IncludeStatus == IncludeStatus.ApiRoot || thinTypeForwarder.IncludeStatus == IncludeStatus.ApiFxInternal) { nApiTypeForwarders++; } } else { Console.Error.WriteLine("BclRewriter : warning BR5001 : couldn't find declaring module of type forwarder {0} in closure", typeForwarder); } } foreach (ITypeDefinitionMember member in _depot.MembersClosure.Keys) { INamedTypeDefinition type = Util.ContainingTypeDefinition(member); if (types.ContainsKey(type)) { ThinType declaringType = types[type]; IncludeStatus status = GetIncludeStatus(member); VisibilityOverride vis = VisibilityOverride.None; if (ShouldHideMember(member)) vis = VisibilityOverride.Internal; if ((type.IsInterface) && TypeIsVisibleInApi(type) && vis == VisibilityOverride.Internal) { throw new Exception(string.Format("Implementation required non-public member on public interface: {0} on {1}. This usually means you added a property to model.xml without adding the corresponding getter or setter.", member.Name, Util.FullyQualifiedTypeNameFromType(member.ContainingType))); } ThinMember thinMember = new ThinMember(declaringType, member, status, vis); declaringType.Members.Add(thinMember.Key, thinMember); if (thinMember.IncludeStatus == IncludeStatus.ApiClosure || thinMember.IncludeStatus == IncludeStatus.ApiRoot || thinMember.IncludeStatus == IncludeStatus.ApiFxInternal) { nApiMembers++; } } else { Console.Error.WriteLine("BclRewriter : warning BR5002 : couldn't find declaring type of member {0} in closure", member); } } foreach (IMethodDefinition method in _depot.MethodsClosure.Values) { INamedTypeDefinition type = Util.ContainingTypeDefinition(method); if (types.ContainsKey(type)) { ThinType declaringType = types[type]; IncludeStatus status = GetIncludeStatus(method); VisibilityOverride vis = VisibilityOverride.None; if (ShouldHideMember(method)) vis = VisibilityOverride.Internal; if ((type.IsInterface) && TypeIsVisibleInApi(type) && vis == VisibilityOverride.Internal) { //throw new Exception(string.Format("WARNING: implementation required non-public member on public interface: {0} on {1}. This usually means you added a property to model.xml without adding the corresponding getter or setter.", // method.Name, // Util.FullyQualifiedTypeNameFromType(method.ContainingType))); } ThinMember thinMember = new ThinMember(declaringType, method, status, vis); if (declaringType.Members.ContainsKey(thinMember.Key)) { throw new Exception(String.Format("Found two members with the same signature: {0}", thinMember.Key)); } declaringType.Members.Add(thinMember.Key, thinMember); if (thinMember.IncludeStatus == IncludeStatus.ApiClosure || thinMember.IncludeStatus == IncludeStatus.ApiRoot || thinMember.IncludeStatus == IncludeStatus.ApiFxInternal) { nApiMembers++; } } else { Console.Error.WriteLine("BclRewriter : warning BR5003 : couldn't find declaring type of method {0} in closure", method); } } foreach (ThinMember thinMember in _missingMembers) { ThinType typeToExtend = types[thinMember.DeclaringType.Metadata]; ThinMember newThinMember = new ThinMember(typeToExtend, thinMember); if (!typeToExtend.Members.ContainsKey(newThinMember.Key)) typeToExtend.Members.Add(newThinMember.Key, newThinMember); } return thinModel; }
public override MemberElement CreateMemberElement(TypeElement type, string memberName, string returnType, MemberTypes memberType, IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus) { TrimType typeInfo = (TrimType)type; TrimMember id = new TrimMember(typeInfo, memberName, returnType, /*paramListString, */memberType, includeStatus, visibilityOverride, securityTransparencyStatus); typeInfo.Members.Add(id.Key, id); return id; }
public void ImportRoots(IncludeStatus rootType) { ImportWorker(rootType, AddRootAssembly, AddRootType, AddRootTypeForwarder, AddRootMember); }
public TrimMember(TrimType declaringType, string memberName, string returnType, /*string paramListString, */MemberTypes memberType, IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus) { _declaringType = declaringType; _memberName = memberName; _returnType = returnType; _memberType = memberType; _includeStatus = includeStatus; _securityTransparencyStatus = securityTransparencyStatus; //_paramListString = paramListString; //if (null == paramListString) // _paramQualifiedTypeNames = new List<string>(); //else // _paramQualifiedTypeNames = SplitParameterList(paramListString); _visibilityOverride = visibilityOverride; }
public override TypeElement CreateTypeElement(AssemblyElement assembly, string typeName, IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus) { TrimAssembly trimAssembly = (TrimAssembly)assembly; TrimType typeIncludeInfo = new TrimType(typeName, includeStatus, visibilityOverride, securityTransparencyStatus); trimAssembly.Types.Add(typeIncludeInfo.Key, typeIncludeInfo); return typeIncludeInfo; }
public static bool IsRoot(IncludeStatus status) { return ((status == IncludeStatus.ApiRoot) || (status == IncludeStatus.ImplRoot) || (status == IncludeStatus.ApiFxInternal)); }
public TrimType(String typeName, IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus) { _typeName = typeName; _typeMembers = new Dictionary<string, MemberElement>(); _includeStatus = includeStatus; _visibilityOverride = visibilityOverride; _securityTransparencyStatus = securityTransparencyStatus; }
public override TypeElement CreateTypeElement(AssemblyElement assembly, string typeName, IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus) { TrimAssembly trimAssembly = (TrimAssembly)assembly; TrimType typeIncludeInfo = new TrimType(typeName, includeStatus, visibilityOverride, securityTransparencyStatus); trimAssembly.Types.Add(typeIncludeInfo.Key, typeIncludeInfo); return(typeIncludeInfo); }
public override TypeElement CreateTypeElement(AssemblyElement assembly, string typeName, IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus) { ThinAssembly declaringAssembly = (ThinAssembly)assembly; includeStatus = AdjustIncludeStatus(includeStatus); ThinType type = new ThinType(declaringAssembly, typeName, includeStatus, null, visibilityOverride, securityTransparencyStatus); String key = type.Name; if (declaringAssembly.Types.ContainsKey(key)) { String errMsg = String.Format("XML file error: duplicate Type element \"{0}\"", key); Console.Error.WriteLine(errMsg); throw new FormatException(errMsg); } declaringAssembly.Types.Add(key, type); return type; }
public override MemberElement CreateMemberElement(TypeElement type, string memberName, string returnType, MemberTypes memberType, IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus) { TrimType typeInfo = (TrimType)type; TrimMember id = new TrimMember(typeInfo, memberName, returnType, /*paramListString, */ memberType, includeStatus, visibilityOverride, securityTransparencyStatus); typeInfo.Members.Add(id.Key, id); return(id); }
public override TypeForwarderElement CreateTypeForwarderElement(AssemblyElement parent, string assemblyName, string typeName, IncludeStatus includeStatus) { TrimAssembly trimAssembly = (TrimAssembly)parent; TrimTypeForwarder typeForwarder = new TrimTypeForwarder(assemblyName, typeName, includeStatus); trimAssembly.TypeForwarders.Add(typeForwarder.Key, typeForwarder); return(typeForwarder); }
internal CodeTypeForwarderElement(IncludeStatus includeStatus, string assemblyName, string typeName) { _includeStatus = includeStatus; _assemblyName = assemblyName; _typeName = typeName; }
// Special case: If closureStatus == ApiRoot this will automatically // convert it to ImplRoot for internal types // TODO: Visitor should set status instead of this. public ThinModel ExportModel(IncludeStatus closureStatus) { _closureStatus = closureStatus; int nApiTypes = 0; int nApiTypeForwarders = 0; int nApiMembers = 0; ThinModel thinModel = new ThinModel(_thinModel.Options); Dictionary <String, ThinAssembly> assemblies = new Dictionary <String, ThinAssembly>(_depot.AssembliesClosure.Count); Dictionary <INamedTypeDefinition, ThinType> types = new Dictionary <INamedTypeDefinition, ThinType>(_depot.TypesClosure.Count); foreach (IAssembly assembly in _depot.AssembliesClosure.Values) { ThinAssembly thinAsm = new ThinAssembly(_thinModel, assembly.Name.Value, GetIncludeStatus(assembly), assembly); thinModel.Assemblies.Add(thinAsm.Name, thinAsm); assemblies.Add(assembly.Name.Value, thinAsm); } foreach (INamedTypeDefinition type in _depot.TypesClosure.Values) { IAssembly asm = TypeHelper.GetDefiningUnit(type) as IAssembly; if (asm != null && assemblies.ContainsKey(asm.Name.Value)) { VisibilityOverride vis = VisibilityOverride.None; if (ShouldHideType(type)) { vis = VisibilityOverride.Internal; } if (closureStatus != IncludeStatus.ApiRoot) { if (TypeIsVisibleInApi(type)) { INamedTypeDefinition curType = type; while (curType != null && curType != Dummy.Type && // TODO: Remove dummy check? CanInclude(curType)) { if (WeHidThisType(curType)) { throw new Exception("API closure error! Base type " + curType + " was hidden, but " + type + " is in the public API"); } ITypeReference curTypeRef = TypeHelper.BaseClass(curType); curType = curTypeRef != null?Util.CanonicalizeType(curTypeRef) : null; } } } ThinAssembly declaringAssembly = assemblies[asm.Name.Value]; ThinType thinType = new ThinType(declaringAssembly, Util.FullyQualifiedTypeNameFromType(type), GetIncludeStatus(type), type, vis); declaringAssembly.Types.Add(thinType.Name, thinType); types.Add(type, thinType); if (thinType.IncludeStatus == IncludeStatus.ApiClosure || thinType.IncludeStatus == IncludeStatus.ApiRoot || thinType.IncludeStatus == IncludeStatus.ApiFxInternal) { nApiTypes++; } } else { Console.Error.WriteLine("BclRewriter : warning BR5004 : couldn't find declaring module of type {0} in closure", type); } } foreach (IAliasForType typeForwarder in _depot.TypeForwardersClosure.Values) { // TODO: Why is this getting an immutable copy of the assembly? IAssembly asm = Util.GetDefiningAssembly(typeForwarder); if (asm != null && assemblies.ContainsKey(asm.Name.Value)) { ThinAssembly declaringAssembly = assemblies[asm.Name.Value]; ITypeReference aliasedType = typeForwarder.AliasedType; ThinTypeForwarder thinTypeForwarder = new ThinTypeForwarder(declaringAssembly, Util.GetDefiningAssembly(aliasedType).Name.Value, Util.GetTypeName(aliasedType), GetIncludeStatus(typeForwarder), typeForwarder); declaringAssembly.TypeForwarders.Add(thinTypeForwarder.Key, thinTypeForwarder); if (thinTypeForwarder.IncludeStatus == IncludeStatus.ApiClosure || thinTypeForwarder.IncludeStatus == IncludeStatus.ApiRoot || thinTypeForwarder.IncludeStatus == IncludeStatus.ApiFxInternal) { nApiTypeForwarders++; } } else { Console.Error.WriteLine("BclRewriter : warning BR5001 : couldn't find declaring module of type forwarder {0} in closure", typeForwarder); } } foreach (ITypeDefinitionMember member in _depot.MembersClosure.Keys) { INamedTypeDefinition type = Util.ContainingTypeDefinition(member); if (types.ContainsKey(type)) { ThinType declaringType = types[type]; IncludeStatus status = GetIncludeStatus(member); VisibilityOverride vis = VisibilityOverride.None; if (ShouldHideMember(member)) { vis = VisibilityOverride.Internal; } if ((type.IsInterface) && TypeIsVisibleInApi(type) && vis == VisibilityOverride.Internal) { throw new Exception(string.Format("Implementation required non-public member on public interface: {0} on {1}. This usually means you added a property to model.xml without adding the corresponding getter or setter.", member.Name, Util.FullyQualifiedTypeNameFromType(member.ContainingType))); } ThinMember thinMember = new ThinMember(declaringType, member, status, vis); declaringType.Members.Add(thinMember.Key, thinMember); if (thinMember.IncludeStatus == IncludeStatus.ApiClosure || thinMember.IncludeStatus == IncludeStatus.ApiRoot || thinMember.IncludeStatus == IncludeStatus.ApiFxInternal) { nApiMembers++; } } else { Console.Error.WriteLine("BclRewriter : warning BR5002 : couldn't find declaring type of member {0} in closure", member); } } foreach (IMethodDefinition method in _depot.MethodsClosure.Values) { INamedTypeDefinition type = Util.ContainingTypeDefinition(method); if (types.ContainsKey(type)) { ThinType declaringType = types[type]; IncludeStatus status = GetIncludeStatus(method); VisibilityOverride vis = VisibilityOverride.None; if (ShouldHideMember(method)) { vis = VisibilityOverride.Internal; } if ((type.IsInterface) && TypeIsVisibleInApi(type) && vis == VisibilityOverride.Internal) { //throw new Exception(string.Format("WARNING: implementation required non-public member on public interface: {0} on {1}. This usually means you added a property to model.xml without adding the corresponding getter or setter.", // method.Name, // Util.FullyQualifiedTypeNameFromType(method.ContainingType))); } ThinMember thinMember = new ThinMember(declaringType, method, status, vis); if (declaringType.Members.ContainsKey(thinMember.Key)) { throw new Exception(String.Format("Found two members with the same signature: {0}", thinMember.Key)); } declaringType.Members.Add(thinMember.Key, thinMember); if (thinMember.IncludeStatus == IncludeStatus.ApiClosure || thinMember.IncludeStatus == IncludeStatus.ApiRoot || thinMember.IncludeStatus == IncludeStatus.ApiFxInternal) { nApiMembers++; } } else { Console.Error.WriteLine("BclRewriter : warning BR5003 : couldn't find declaring type of method {0} in closure", method); } } foreach (ThinMember thinMember in _missingMembers) { ThinType typeToExtend = types[thinMember.DeclaringType.Metadata]; ThinMember newThinMember = new ThinMember(typeToExtend, thinMember); if (!typeToExtend.Members.ContainsKey(newThinMember.Key)) { typeToExtend.Members.Add(newThinMember.Key, newThinMember); } } return(thinModel); }
internal CodeTypeElement(IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus, string key) { m_members = new Dictionary<string, MemberElement>(); _includeStatus = includeStatus; _visibilityOverride = visibilityOverride; _securityTransparencyStatus = securityTransparencyStatus; _key = key; }
public override TypeForwarderElement CreateTypeForwarderElement(AssemblyElement parent, string assemblyName, string typeName, IncludeStatus includeStatus) { ThinAssembly declaringAssembly = (ThinAssembly)parent; includeStatus = AdjustIncludeStatus(includeStatus); ThinTypeForwarder typeForwarder = new ThinTypeForwarder(declaringAssembly, assemblyName, typeName, includeStatus, null); String key = typeForwarder.Key; if (declaringAssembly.Types.ContainsKey(key)) { String errMsg = String.Format("XML file error: duplicate TypeForwarder element for \"{0}\"", key); Console.Error.WriteLine(errMsg); throw new FormatException(errMsg); } declaringAssembly.TypeForwarders.Add(key, typeForwarder); return typeForwarder; }
public static bool IsRoot(IncludeStatus status) { return((status == IncludeStatus.ApiRoot) || (status == IncludeStatus.ImplRoot) || (status == IncludeStatus.ApiFxInternal)); }
public override MemberElement CreateMemberElement(TypeElement type, string memberName, string returnType, MemberTypes memberType, IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus) { ThinType declaringType = (ThinType)type; includeStatus = AdjustIncludeStatus(includeStatus); ThinMember member = new ThinMember(declaringType, memberName, returnType, memberType, includeStatus, null, visibilityOverride, securityTransparencyStatus); String key = member.Key; if (declaringType.Members.ContainsKey(key)) { String errMsg = String.Format("XML file error: duplicate Member element \"{0}\" in type \"{1}\"", key, type.Key); Console.Error.WriteLine(errMsg); throw new FormatException(errMsg); } declaringType.Members.Add(key, member); return member; }
public static bool IsApi(IncludeStatus status) { return ((status == IncludeStatus.ApiRoot) || (status == IncludeStatus.ApiClosure) || (status == IncludeStatus.ApiFxInternal)); }
public TrimTypeForwarder(String assemblyName, String typeName, IncludeStatus includeStatus) { _assemblyName = assemblyName; _typeName = typeName; _includeStatus = includeStatus; }
abstract public AssemblyElement CreateAssemblyElement(ModelElement model, string assemblyName, IncludeStatus includeStatus);
public override AssemblyElement CreateAssemblyElement(ModelElement model, string assemblyName, IncludeStatus includeStatus) { IncludeSet includeSet = (IncludeSet)model; TrimAssembly trimAssembly = new TrimAssembly(assemblyName, includeStatus); ; includeSet.AddAssembly(trimAssembly); return trimAssembly; }
abstract public TypeForwarderElement CreateTypeForwarderElement(AssemblyElement parent, string assemblyName, string typeName, IncludeStatus includeStatus);
public override TypeForwarderElement CreateTypeForwarderElement(AssemblyElement parent, string assemblyName, string typeName, IncludeStatus includeStatus) { TrimAssembly trimAssembly = (TrimAssembly)parent; TrimTypeForwarder typeForwarder = new TrimTypeForwarder(assemblyName, typeName, includeStatus); trimAssembly.TypeForwarders.Add(typeForwarder.Key, typeForwarder); return typeForwarder; }
public override AssemblyElement CreateAssemblyElement(ModelElement model, string assemblyName, IncludeStatus includeStatus) { CodeAssemblyElement assembly = new CodeAssemblyElement(includeStatus, assemblyName); (model as CodeModelElement).m_assemblies.Add(assemblyName, assembly); return(assembly); }
public TrimAssembly(string assemblyName, IncludeStatus status) { _name = assemblyName; _includeStatus = status; _types = new Dictionary<string, TypeElement>(); _typeForwarders = new Dictionary<string, TypeForwarderElement>(); }
public override TypeForwarderElement CreateTypeForwarderElement(AssemblyElement parent, string assemblyName, string typeName, IncludeStatus includeStatus) { CodeTypeForwarderElement typeForwarder = new CodeTypeForwarderElement(includeStatus, assemblyName, typeName); (parent as CodeAssemblyElement).TypeForwarders.Add(typeForwarder.Key, typeForwarder); return(typeForwarder); }
private void ImportWorker(IncludeStatus statusToImport, AddAssembly addAssembly, AddType addType, AddTypeForwarder addTypeForwarder, AddMember addMember) { foreach (ThinAssembly assembly in _thinModel.Assemblies.Values) { if (assembly.IncludeStatus == statusToImport) addAssembly(assembly); foreach (ThinTypeForwarder typeForwarder in assembly.TypeForwarders.Values) { if (typeForwarder.IncludeStatus == statusToImport) { // Assembly may not have already been added because they might not have the correct IncludedStatus. addAssembly(assembly); addTypeForwarder(typeForwarder); } } foreach (ThinType type in assembly.Types.Values) { if (type.IncludeStatus == statusToImport) { // Assembly may not have already been added because they might not have the correct IncludedStatus. addAssembly(assembly); addType(type); } foreach (ThinMember member in type.Members.Values) { if (member.IncludeStatus == statusToImport) { // Assembly and Type may not have already been added because they might not have the correct IncludedStatus. addAssembly(assembly); addType(type); addMember(member); } } } } }
internal CodeAssemblyElement(IncludeStatus includeStatus, string key) { m_types = new Dictionary<string, TypeElement>(); m_typeForwarders = new Dictionary<string, TypeForwarderElement>(); _includeStatus = includeStatus; _key = key; }
public override AssemblyElement CreateAssemblyElement(ModelElement model, string assemblyName, IncludeStatus includeStatus) { IncludeSet includeSet = (IncludeSet)model; TrimAssembly trimAssembly = new TrimAssembly(assemblyName, includeStatus);; includeSet.AddAssembly(trimAssembly); return(trimAssembly); }
public static bool IsApi(IncludeStatus status) { return((status == IncludeStatus.ApiRoot) || (status == IncludeStatus.ApiClosure) || (status == IncludeStatus.ApiFxInternal)); }
public void RecursivelyReadBlock(XmlReader reader, object parentObj, bool include) { while (reader.Read() && (reader.NodeType != XmlNodeType.EndElement)) { XmlParseAssert(reader.IsStartElement()); switch (reader.Name) { case XmlKeywords.Elements.Xml: { XmlParseAssert(include); XmlParseAssert(parentObj is ModelElement); RecursivelyReadBlock(reader, parentObj, true); break; } case XmlKeywords.Elements.ThinModel: { XmlParseAssert(include); XmlParseAssert(parentObj is ModelElement); RecursivelyReadBlock(reader, parentObj, true); break; } case XmlKeywords.Elements.Assembly: { XmlParseAssert(include); XmlParseAssert(parentObj is ModelElement); XmlParseAssert(reader.AttributeCount > 0); string assemblyName = reader.GetAttribute(XmlKeywords.Attributes.Name); XmlParseAssert(assemblyName != null); string includeStatusString = reader.GetAttribute(XmlKeywords.Attributes.IncludeStatus); IncludeStatus includeStatus = IncludeStatus.Inherit; if (includeStatusString != null) { includeStatus = XmlKeywords.ParseIncludeStatus(includeStatusString); } string platform = reader.GetAttribute(XmlKeywords.Attributes.Platform); string architecture = reader.GetAttribute(XmlKeywords.Attributes.Architecture); string flavor = reader.GetAttribute(XmlKeywords.Attributes.Flavor); string condition = reader.GetAttribute(XmlKeywords.Attributes.Condition); bool included = IncludeBuild(platform, architecture, flavor, condition); AssemblyElement assembly = null; if (included) { assembly = CreateAssemblyElement((ModelElement)parentObj, assemblyName, includeStatus); } if (!reader.IsEmptyElement) { RecursivelyReadBlock(reader, assembly, included); } break; } case XmlKeywords.Elements.Type: { TypeElement type = null; bool included = false; if (include) { XmlParseAssert(parentObj is AssemblyElement); XmlParseAssert(reader.AttributeCount > 0); string fullyQualifiedTypeName = reader.GetAttribute(XmlKeywords.Attributes.Name); XmlParseAssert(fullyQualifiedTypeName != null); AssemblyElement declaringAssembly = (AssemblyElement)parentObj; IncludeStatus includeStatus = declaringAssembly.IncludeStatus; string includeStatusString = reader.GetAttribute(XmlKeywords.Attributes.IncludeStatus); if (includeStatusString != null) { includeStatus = XmlKeywords.ParseIncludeStatus(includeStatusString); } SecurityTransparencyStatus securityTransparencyStatus = SecurityTransparencyStatus.Transparent; string securityTransparencyStatusString = reader.GetAttribute(XmlKeywords.Attributes.SecurityTransparencyStatus); if (securityTransparencyStatusString != null) { securityTransparencyStatus = XmlKeywords.ParseSecurityTransparencyStatus(securityTransparencyStatusString); } string visibilityOverrideString = reader.GetAttribute(XmlKeywords.Attributes.VisibilityOverride); VisibilityOverride visibilityOverride = XmlKeywords.ParseVisibilityOverride(visibilityOverrideString); string platform = reader.GetAttribute(XmlKeywords.Attributes.Platform); string architecture = reader.GetAttribute(XmlKeywords.Attributes.Architecture); string flavor = reader.GetAttribute(XmlKeywords.Attributes.Flavor); string condition = reader.GetAttribute(XmlKeywords.Attributes.Condition); included = IncludeBuild(platform, architecture, flavor, condition); if (included) { type = CreateTypeElement(declaringAssembly, fullyQualifiedTypeName, includeStatus, visibilityOverride, securityTransparencyStatus); } } if (!reader.IsEmptyElement) { RecursivelyReadBlock(reader, type, included); } break; } case XmlKeywords.Elements.TypeForwarder: { TypeForwarderElement type = null; bool included = false; if (include) { XmlParseAssert(parentObj is AssemblyElement); XmlParseAssert(reader.AttributeCount > 1); string assemblyName = reader.GetAttribute(XmlKeywords.Attributes.AssemblyName); string typeName = reader.GetAttribute(XmlKeywords.Attributes.TypeName); XmlParseAssert(assemblyName != null); XmlParseAssert(typeName != null); AssemblyElement declaringAssembly = (AssemblyElement)parentObj; IncludeStatus includeStatus = declaringAssembly.IncludeStatus; string includeStatusString = reader.GetAttribute(XmlKeywords.Attributes.IncludeStatus); if (includeStatusString != null) { includeStatus = XmlKeywords.ParseIncludeStatus(includeStatusString); } string platform = reader.GetAttribute(XmlKeywords.Attributes.Platform); string architecture = reader.GetAttribute(XmlKeywords.Attributes.Architecture); string flavor = reader.GetAttribute(XmlKeywords.Attributes.Flavor); string condition = reader.GetAttribute(XmlKeywords.Attributes.Condition); included = IncludeBuild(platform, architecture, flavor, condition); if (included) { type = CreateTypeForwarderElement(declaringAssembly, assemblyName, typeName, includeStatus); } } if (!reader.IsEmptyElement) { RecursivelyReadBlock(reader, type, included); } break; } case XmlKeywords.Elements.Member: { if (include) { XmlParseAssert(parentObj is TypeElement); XmlParseAssert(reader.AttributeCount > 0); string memberName = reader.GetAttribute(XmlKeywords.Attributes.Name); XmlParseAssert(memberName != null); TypeElement declaringType = (TypeElement)parentObj; string returnType = reader.GetAttribute(XmlKeywords.Attributes.ReturnType); string memberTypeString = reader.GetAttribute(XmlKeywords.Attributes.MemberType); MemberTypes memberType = XmlKeywords.ParseMemberType(memberTypeString); XmlParseAssert(memberType != MemberTypes.Unknown); IncludeStatus includeStatus = declaringType.IncludeStatus; string includeStatusString = reader.GetAttribute(XmlKeywords.Attributes.IncludeStatus); if (includeStatusString != null) { includeStatus = XmlKeywords.ParseIncludeStatus(includeStatusString); } if (includeStatus == IncludeStatus.Inherit) { throw new FormatException(String.Format("Specify include status for Member \"{0}\" in Type \"{1}\"", memberName, declaringType.Key)); } XmlParseAssert(includeStatus != IncludeStatus.Inherit); // Inherited virtual members "sometimes" don't inherit transparency status (when following certain rulesets) and we don't know // inheritance or rule status here. Therefore we can't say what the transparency status is here unless it's explicitly defined. SecurityTransparencyStatus securityTransparencyStatus = SecurityTransparencyStatus.Undefined; string securityTransparencyStatusString = reader.GetAttribute(XmlKeywords.Attributes.SecurityTransparencyStatus); if (securityTransparencyStatusString != null) { securityTransparencyStatus = XmlKeywords.ParseSecurityTransparencyStatus(securityTransparencyStatusString); } string visibilityOverrideString = reader.GetAttribute(XmlKeywords.Attributes.VisibilityOverride); VisibilityOverride visibilityOverride = XmlKeywords.ParseVisibilityOverride(visibilityOverrideString); string platform = reader.GetAttribute(XmlKeywords.Attributes.Platform); string architecture = reader.GetAttribute(XmlKeywords.Attributes.Architecture); string flavor = reader.GetAttribute(XmlKeywords.Attributes.Flavor); string condition = reader.GetAttribute(XmlKeywords.Attributes.Condition); bool included = IncludeBuild(platform, architecture, flavor, condition); if (included) { CreateMemberElement(declaringType, memberName, returnType, memberType, includeStatus, visibilityOverride, securityTransparencyStatus); } } break; } } } }
private IncludeStatus AdjustIncludeStatus(IncludeStatus includeStatus) { if (_options.TreatFxInternalAsPublic && includeStatus == IncludeStatus.ApiFxInternal) return IncludeStatus.ApiRoot; return includeStatus; }
abstract public TypeElement CreateTypeElement(AssemblyElement assembly, string typeName, IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus);
private void CombineIncludeStatusWithModel(IncludeStatus targetStatusToAdd, ThinModel otherModel) { // TODO: which one should we keep, the one in this model or the other model? foreach (ThinAssembly assembly in Assemblies.Values) { AssemblyElement newAssembly; if (!otherModel.Assemblies.TryGetValue(assembly.Name, out newAssembly) && (assembly.IncludeStatus == targetStatusToAdd)) { newAssembly = new ThinAssembly(otherModel, assembly); otherModel.Assemblies.Add(newAssembly.Key, newAssembly); } foreach (ThinTypeForwarder typeForwarder in assembly.TypeForwarders.Values) { TypeForwarderElement newTypeForwarder; if (!newAssembly.TypeForwarders.TryGetValue(typeForwarder.Key, out newTypeForwarder) && (typeForwarder.IncludeStatus == targetStatusToAdd)) { newTypeForwarder = new ThinTypeForwarder((ThinAssembly)newAssembly, typeForwarder); newAssembly.TypeForwarders.Add(newTypeForwarder.Key, newTypeForwarder); } } foreach (ThinType type in assembly.Types.Values) { TypeElement newType; if (!newAssembly.Types.TryGetValue(type.Name, out newType) && (type.IncludeStatus == targetStatusToAdd)) { newType = new ThinType((ThinAssembly)newAssembly, type); newAssembly.Types.Add(newType.Key, newType); } foreach (ThinMember member in type.Members.Values) { MemberElement newMember; if (!newType.Members.TryGetValue(member.Key, out newMember) && (member.IncludeStatus == targetStatusToAdd)) { newMember = new ThinMember((ThinType)newType, member); newType.Members.Add(newMember.Key, newMember); } } } } }
abstract public MemberElement CreateMemberElement(TypeElement type, string memberName, string returnType, MemberTypes memberType, IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus);
public override AssemblyElement CreateAssemblyElement(ModelElement model, string assemblyName, IncludeStatus includeStatus) { CodeAssemblyElement assembly = new CodeAssemblyElement(includeStatus, assemblyName); (model as CodeModelElement).m_assemblies.Add(assemblyName, assembly); return assembly; }
public override TypeElement CreateTypeElement(AssemblyElement assembly, string typeName, IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus) { CodeTypeElement type = new CodeTypeElement(includeStatus, visibilityOverride, securityTransparencyStatus, typeName); (assembly as CodeAssemblyElement).m_types.Add(typeName, type); return(type); }
public override TypeElement CreateTypeElement(AssemblyElement assembly, string typeName, IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus) { CodeTypeElement type = new CodeTypeElement(includeStatus, visibilityOverride, securityTransparencyStatus, typeName); (assembly as CodeAssemblyElement).m_types.Add(typeName, type); return type; }
public override MemberElement CreateMemberElement(TypeElement type, string memberName, string returnType, MemberTypes memberType, IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus) { // Identify the member by category (method/prop/field/event), name, and return type. These // strings are what matched by ModelSigFormatter string memberSig = memberType.ToString() + " : " + memberName; if (returnType != null) { memberSig = memberSig + " : " + returnType; } CodeMemberElement member = new CodeMemberElement(includeStatus, visibilityOverride, securityTransparencyStatus, memberSig, returnType, memberType, memberName); (type as CodeTypeElement).m_members.Add(memberSig, member); return(member); }
public override TypeForwarderElement CreateTypeForwarderElement(AssemblyElement parent, string assemblyName, string typeName, IncludeStatus includeStatus) { CodeTypeForwarderElement typeForwarder = new CodeTypeForwarderElement(includeStatus, assemblyName, typeName); (parent as CodeAssemblyElement).TypeForwarders.Add(typeForwarder.Key, typeForwarder); return typeForwarder; }