public XElement GenerateXml() { var allAttributes = GetAllAttributes(); return(new XElement( "Attributes", from attribute in allAttributes.Keys where _attributeIdentifierGenerator.GetIdentifier(attribute, "none") != "none" select GenerateAttributeElement(attribute, allAttributes))); }
private XElement CreateMemberElement(InvolvedTypeMember member) { MemberInfo memberInfo = member.MemberInfo; var memberModifier = _memberModifierUtility.GetMemberModifiers(memberInfo); if (memberModifier.Contains("private")) // memberModifier.Contains ("internal") { return(null); } var memberName = GetMemberName(memberInfo); var attributes = new StringBuilder(); XElement overridesElement = null; XElement overriddenElement = null; if (_involvedType != null) { if (HasOverrideMixinAttribute(memberInfo)) { attributes.Append("OverrideMixin "); } if (HasOverrideTargetAttribute(memberInfo)) { attributes.Append("OverrideTarget "); } overridesElement = CreateOverridesElement(member); overriddenElement = CreateOverriddenElement(member.MemberInfo); } if (memberInfo.DeclaringType != _type && overridesElement == null && overriddenElement == null) { return(null); } var element = new XElement("Member", new XAttribute("id", _memberIdentifierGenerator.GetIdentifier(memberInfo)), new XAttribute("metadataToken", GetMetadataToken(memberInfo)), new XAttribute("type", memberInfo.MemberType), new XAttribute("name", memberName), new XAttribute("is-declared-by-this-class", memberInfo.DeclaringType == _type), _outputFormatter.CreateModifierMarkup(attributes.ToString(), memberModifier), _memberSignatureUtility.GetMemberSignature(memberInfo), member.SubMemberInfos.Select(CreateSubMemberElement), overridesElement, overriddenElement); return(element); }
private XElement CreateInvolvedTypeElement(InvolvedType involvedType) { var realType = involvedType.Type; var element = new XElement( "InvolvedType", new XAttribute("id", _involvedTypeIdentifierGenerator.GetIdentifier(realType)), new XAttribute("metadataToken", realType.MetadataToken), new XAttribute("assembly-ref", _assemblyIdentifierGenerator.GetIdentifier(realType.Assembly)), new XAttribute("namespace", realType.Namespace), new XAttribute("name", _outputFormatter.GetShortFormattedTypeName(realType)), new XAttribute("base", GetCSharpLikeNameForBaseType(realType)), new XAttribute("base-ref", GetBaseReference(realType)), new XAttribute("is-target", involvedType.IsTarget), new XAttribute("is-mixin", involvedType.IsMixin), new XAttribute("is-unusedmixin", !involvedType.IsTarget && !involvedType.IsMixin && _remotionReflector.IsInheritedFromMixin(involvedType.Type) && !_remotionReflector.IsInfrastructureType(involvedType.Type)), new XAttribute("is-generic-definition", realType.IsGenericTypeDefinition), new XAttribute("is-interface", realType.IsInterface), _outputFormatter.CreateModifierMarkup(GetAlphabeticOrderingAttribute(involvedType), _typeModifierUtility.GetTypeModifiers(realType)), _summaryPicker.GetSummary(realType), new MemberReportGenerator(realType, involvedType, _involvedTypeIdentifierGenerator, _memberIdentifierGenerator, _outputFormatter).GenerateXml(), new InterfaceReferenceReportGenerator( involvedType, _interfaceIdentifierGenerator, _remotionReflector).GenerateXml(), new AttributeReferenceReportGenerator( realType, _attributeIdentifierGenerator, _remotionReflector).GenerateXml(), new MixinReferenceReportGenerator( involvedType, _assemblyIdentifierGenerator, _involvedTypeIdentifierGenerator, _interfaceIdentifierGenerator, _attributeIdentifierGenerator, _remotionReflector, _outputFormatter).GenerateXml(), new TargetReferenceReportGenerator( involvedType, _involvedTypeIdentifierGenerator).GenerateXml() ); if (realType.IsGenericType && !realType.IsGenericTypeDefinition) { element.Add(new XAttribute("generic-definition-ref", _involvedTypeIdentifierGenerator.GetIdentifier(realType.GetGenericTypeDefinition()))); } return(element); }
private XElement GenerateTargetElement(Type targetType) { return(new XElement( "Target", new XAttribute("ref", _involvedTypeIdentifierGenerator.GetIdentifier(targetType)) )); }
private XElement CreateDependencyElement(ReflectedObject targetCallDependencyDefinition) { var targetClassDefinition = _mixinDefinition.GetProperty("TargetClass"); var requiredType = targetCallDependencyDefinition.GetProperty("RequiredType").GetProperty("Type").To <Type> (); var element = new XElement("Dependency", new XAttribute("assembly-ref", _assemblyIdentifierGenerator.GetIdentifier(requiredType.Assembly)), new XAttribute("metadataToken", requiredType.MetadataToken), new XAttribute("namespace", requiredType.Namespace), new XAttribute("name", _outputFormatter.GetShortFormattedTypeName(requiredType)), new XAttribute("is-interface", requiredType.IsInterface)); if (requiredType.IsInterface) { var implementedByTarget = targetClassDefinition.GetProperty("ImplementedInterfaces").Any(i => i.To <Type> () == requiredType); var addedByMixin = targetClassDefinition.GetProperty("ReceivedInterfaces").Any(i => i.GetProperty("InterfaceType").To <Type> () == requiredType); var implementedDynamically = !implementedByTarget && !addedByMixin; element.Add(new XAttribute("is-implemented-by-target", implementedByTarget)); element.Add(new XAttribute("is-added-by-mixin", addedByMixin)); element.Add(new XAttribute("is-implemented-dynamically", implementedDynamically)); } return(element); }
private XElement GenerateAttributeReferanceElement(Type introducedAttribute) { return(new XElement( "IntroducedAttribute", new XAttribute("ref", _attributeIdentifierGenerator.GetIdentifier(introducedAttribute)) )); }
public XElement GenerateXml() { return(new XElement( "AdditionalDependencies", from explicitDependencyType in _explicitDependencies select new XElement( "AdditionalDependency", new XAttribute("ref", _involvedTypeIdentifierGenerator.GetIdentifier(explicitDependencyType.To <Type>())), new XAttribute("instance-name", _outputFormatter.GetShortFormattedTypeName(explicitDependencyType.To <Type>())) ) )); }
private XElement GenerateInterfaceReferenceElement(Type introducedInterface) { /* * MixinDefinition ab; * ab.InterfaceIntroductions[0].IntroducedMethods[0].Visibility; * ab.InterfaceIntroductions[0].IntroducedMethods[0].Name; * ab.InterfaceIntroductions[0].IntroducedProperties; * ab.InterfaceIntroductions[0].IntroducedEvents */ return(new XElement( "IntroducedInterface", new XAttribute("ref", _interfaceIdentifierGenerator.GetIdentifier(introducedInterface)) //, GenerateMemberIntroductions )); }
private XElement GenerateAttributeElement(Type attribute, Dictionary <Type, List <Type> > allAttributes) { return(new XElement( "Attribute", new XAttribute("id", _attributeIdentifierGenerator.GetIdentifier(attribute)), new XAttribute("assembly-ref", _assemblyIdentifierGenerator.GetIdentifier(attribute.Assembly)), new XAttribute("namespace", attribute.Namespace), new XAttribute("name", _outputFormatter.GetShortFormattedTypeName(attribute)), new XElement( "AppliedTo", from appliedToType in allAttributes[attribute] select new XElement( "InvolvedType-Reference", new XAttribute("ref", _involvedTypeIdentifierGenerator.GetIdentifier(appliedToType))) ) )); }
private XElement GenerateAssemblyElement(Assembly assembly, IEnumerable <InvolvedType> involvedTypesForAssembly) { return(new XElement( "Assembly", new XAttribute("id", _assemblyIdentifierGenerator.GetIdentifier(assembly)), new XAttribute("name", assembly.GetName().Name), new XAttribute("version", assembly.GetName().Version), new XAttribute("location", GetShortAssemblyLocation(assembly)), new XAttribute("culture", assembly.GetName().CultureInfo), new XAttribute("publicKeyToken", Convert.ToBase64String(assembly.GetName().GetPublicKeyToken())), from involvedType in involvedTypesForAssembly select new XElement( "InvolvedType-Reference", new XAttribute("ref", _involvedTypeIdentifierGenerator.GetIdentifier(involvedType.Type)) ) )); }
private XElement GenerateAttributeReference(CustomAttributeData attribute) { var attributeElement = new XElement( "HasAttribute", new XAttribute("ref", _attributeIdentifierGenerator.GetIdentifier(attribute.Constructor.DeclaringType))); for (int i = 0; i < attribute.ConstructorArguments.Count; i++) { var constructorArgument = attribute.ConstructorArguments[i]; var parameterName = attribute.Constructor.GetParameters()[i].Name; attributeElement.Add(GenerateParameterElement("constructor", constructorArgument.ArgumentType, parameterName, constructorArgument.Value)); } foreach (var namedArgument in attribute.NamedArguments) { attributeElement.Add( GenerateParameterElement("named", namedArgument.TypedValue.ArgumentType, namedArgument.MemberInfo.Name, namedArgument.TypedValue.Value)); } return(attributeElement); }
private XElement GenerateInterfaceElement(Type usedInterface, Dictionary <Type, List <Type> > allInterfaces, bool isComposedInterface) { return(new XElement( "Interface", new XAttribute("id", _interfaceIdentifierGenerator.GetIdentifier(usedInterface)), new XAttribute("assembly-ref", _assemblyIdentifierGenerator.GetIdentifier(usedInterface.Assembly)), new XAttribute("namespace", usedInterface.Namespace), new XAttribute("name", _outputFormatter.GetShortFormattedTypeName(usedInterface)), new XAttribute("is-composed-interface", isComposedInterface), new MemberReportGenerator(usedInterface, new InvolvedType(usedInterface), _involvedTypeIdentifierGenerator, _memberIdentifierGenerator, _outputFormatter).GenerateXml(), new XElement( "ImplementedBy", from implementingType in allInterfaces[usedInterface] select new XElement( "InvolvedType-Reference", new XAttribute("ref", _involvedTypeIdentifierGenerator.GetIdentifier(implementingType))) ) )); }
private XElement GenerateMixinElement(ReflectedObject mixinContext) { var mixinType = mixinContext.GetProperty("MixinType").To <Type>(); var mixinElement = new XElement( "Mixin", new XAttribute("ref", _involvedTypeIdentifierGenerator.GetIdentifier(mixinType)), new XAttribute("index", "n/a"), new XAttribute("relation", GetRelationName(mixinContext)), // property MixinType on mixinContext always return the generic type definition, not the type of the actual instance new XAttribute("instance-name", _outputFormatter.GetShortFormattedTypeName(mixinType)), new XAttribute("introduced-member-visibility", mixinContext.GetProperty("IntroducedMemberVisibility").ToString().ToLower()), new AdditionalDependencyReportGenerator( mixinContext.GetProperty("ExplicitDependencies"), _involvedTypeIdentifierGenerator, _outputFormatter).GenerateXml() ); if (_involvedType.HasTargetClassDefintion) { var mixinDefinition = _involvedType.TargetClassDefinition.CallMethod( "GetMixinByConfiguredType", mixinContext.GetProperty("MixinType").To <Type>()); // set more specific name for mixin references mixinElement.SetAttributeValue("instance-name", _outputFormatter.GetShortFormattedTypeName(mixinDefinition.GetProperty("Type").To <Type>())); // set mixin index mixinElement.SetAttributeValue("index", mixinDefinition.GetProperty("MixinIndex").To <int>()); mixinElement.Add( new InterfaceIntroductionReportGenerator(mixinDefinition.GetProperty("InterfaceIntroductions"), _interfaceIdentifierGenerator). GenerateXml()); mixinElement.Add( new AttributeIntroductionReportGenerator( mixinDefinition.GetProperty("AttributeIntroductions"), _attributeIdentifierGenerator, _remotionReflector).GenerateXml()); mixinElement.Add( new MemberOverrideReportGenerator(mixinDefinition.CallMethod("GetAllOverrides")).GenerateXml()); mixinElement.Add(new TargetCallDependenciesReportGenerator(mixinDefinition, _assemblyIdentifierGenerator, _remotionReflector, _outputFormatter).GenerateXml()); } return(mixinElement); }
private XElement GenerateInterfaceReference(Type implementedInterface) { return(new XElement("ImplementedInterface", new XAttribute("ref", _interfaceIdentifierGenerator.GetIdentifier(implementedInterface)))); }
public void GetIdentifier() { var identifier = _assemblyIdentifierGenerator.GetIdentifier(typeof(IdentifierGeneratorTest).Assembly); Assert.That(identifier, Is.EqualTo("0")); }
public string GetIdentifier(T item) { return(_identifierGenerator.GetIdentifier(item, _defaultValue)); }
private XElement CreateInvolvedTypeReferenceElement(string tagName, Type overridingType) { return(new XElement(tagName, new XAttribute("ref", _involvedTypeIdentifierGenerator.GetIdentifier(overridingType)), new XAttribute("instance-name", _outputFormatter.GetShortFormattedTypeName(overridingType)))); }