示例#1
0
        public void GetSummary_ForNonExistingXmlFile()
        {
            var output         = _summaryPicker.GetSummary(typeof(TargetClass1));
            var expectedOutput = _noSummary;

            Assert.That(output.ToString(), Is.EqualTo(expectedOutput.ToString()));
        }
示例#2
0
        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);
        }
        public void GenerateXml_ForGenericTypeDefinition()
        {
            var involvedType1 = new InvolvedType(typeof(GenericTarget <,>));

            var reportGenerator = CreateInvolvedTypeReportGenerator(involvedType1);
            var output          = reportGenerator.GenerateXml();

            var expectedOutput = new XElement(
                "InvolvedTypes",
                new XElement(
                    "InvolvedType",
                    new XAttribute("id", "0"),
                    new XAttribute("assembly-ref", "0"),
                    new XAttribute("namespace", "MixinXRef.UnitTests.TestDomain"),
                    new XAttribute("name", "GenericTarget<TParameter1, TParameter2>"),
                    new XAttribute("base", "Object"),
                    new XAttribute("base-ref", "none"),
                    new XAttribute("is-target", false),
                    new XAttribute("is-mixin", false),
                    new XAttribute("is-unusedmixin", false),
                    new XAttribute("is-generic-definition", true),
                    new XAttribute("is-interface", false),
                    _outputFormatter.CreateModifierMarkup("", _typeModifierUtility.GetTypeModifiers(involvedType1.Type)),
                    _summaryPicker.GetSummary(involvedType1.Type),
                    new MemberReportGenerator(involvedType1.Type, null, null, _memberIdentifierGenerator, _outputFormatter).GenerateXml(),
                    new InterfaceReferenceReportGenerator(involvedType1, _interfaceIdentifierGenerator, _remotionReflector).GenerateXml(),
                    new AttributeReferenceReportGenerator(involvedType1.Type, _attributeIdentifierGenerator, _remotionReflector).GenerateXml(),
                    new MixinReferenceReportGenerator(
                        involvedType1, _assemblyIdentifierGenerator,
                        _readOnlyInvolvedTypeIdentifierGenerator,
                        _interfaceIdentifierGenerator,
                        _attributeIdentifierGenerator,
                        _remotionReflector,
                        _outputFormatter).
                    GenerateXml(),
                    new TargetReferenceReportGenerator(involvedType1, _readOnlyInvolvedTypeIdentifierGenerator).GenerateXml()
                    ));

            XElementComparisonHelper.Compare(output, expectedOutput);
        }