Esempio n. 1
0
        private MemberDependency GetMemberReferenceMemberDependency(MemberReference memberReference)
        {
            var provider      = new MemberMetadataInfoTypeProvider(_reader);
            var memberRefInfo = provider.GetMemberRefInfo(memberReference);

            // Add the parent type to the types list (only needed when we want to report memberrefs defined in the current assembly)
            if (memberRefInfo.ParentType.IsTypeDef || (memberRefInfo.ParentType.IsPrimitiveType && _currentAssemblyName.Equals("mscorlib", StringComparison.OrdinalIgnoreCase)))
            {
                MemberDependency.Add(CreateMemberDependency(memberRefInfo.ParentType));
            }

            var dep = new MemberDependency
            {
                CallingAssembly = CallingAssembly,
                MemberDocId     = $"{GetPrefix(memberReference)}:{memberRefInfo}",
                TypeDocId       = $"T:{memberRefInfo.ParentType}",
                IsPrimitive     = memberRefInfo.ParentType.IsPrimitiveType
            };

            if (memberRefInfo.ParentType.DefinedInAssembly.HasValue)
            {
                dep.DefinedInAssemblyIdentity = _reader.FormatAssemblyInfo(memberRefInfo.ParentType.DefinedInAssembly.Value);
            }
            // If no assembly is set, then the type is either a primitive type or it's in the current assembly.
            // Mscorlib is special-cased for testing purposes.
            else if (!memberRefInfo.ParentType.IsPrimitiveType || string.Equals(_currentAssemblyName, "mscorlib", StringComparison.OrdinalIgnoreCase))
            {
                dep.DefinedInAssemblyIdentity = _currentAssemblyInfo;
            }

            return(dep);
        }
        public override bool Equals(object obj)
        {
            MemberDependency other = obj as MemberDependency;

            if (other == null)
            {
                return(false);
            }

            return(StringComparer.Ordinal.Equals(MemberDocId, other.MemberDocId) &&
                   StringComparer.Ordinal.Equals(DefinedInAssemblyIdentity, other.DefinedInAssemblyIdentity) &&
                   CallingAssembly.Equals(other.CallingAssembly));
        }
        private MemberDependency GetMemberReferenceMemberDependency(MemberReference memberReference)
        {
            var provider = new MemberMetadataInfoTypeProvider(_reader);
            var memberRefInfo = provider.GetMemberRefInfo(memberReference);

            // Add the parent type to the types list (only needed when we want to report memberrefs defined in the current assembly)
            if (memberRefInfo.ParentType.IsTypeDef || (memberRefInfo.ParentType.IsPrimitiveType && _currentAssemblyName.Equals("mscorlib", StringComparison.OrdinalIgnoreCase)))
            {
                MemberDependency.Add(CreateMemberDependency(memberRefInfo.ParentType));
            }

            var dep = new MemberDependency
            {
                CallingAssembly = CallingAssembly,
                MemberDocId = $"{GetPrefix(memberReference)}:{memberRefInfo}",
                TypeDocId = $"T:{memberRefInfo.ParentType}",
                IsPrimitive = memberRefInfo.ParentType.IsPrimitiveType
            };

            if (memberRefInfo.ParentType.IsAssemblySet)
            {
                dep.DefinedInAssemblyIdentity = _reader.FormatAssemblyInfo(memberRefInfo.ParentType.DefinedInAssembly);
            }
            // If no assembly is set, then the type is either a primitive type or it's in the current assembly.
            // Mscorlib is special-cased for testing purposes.
            else if (!memberRefInfo.ParentType.IsPrimitiveType || string.Equals(_currentAssemblyName, "mscorlib", StringComparison.OrdinalIgnoreCase))
            {
                dep.DefinedInAssemblyIdentity = _currentAssemblyInfo;
            }

            return dep;
        }