Пример #1
0
        private IEnumerable <IPropertySymbol> GetPropertySymbols()
        {
            var allInterfaces = NamedTypeSymbol.GetAllInterfacesIncludingThis();
            var allMembers    = allInterfaces.SelectMany(nts => nts.GetMembers()).ToList();

            var propertySymbols = allMembers.OfType <IPropertySymbol>().ToList();
            var propertyIdSet   = new HashSet <string>();

            // Dedupe overriden properties
            for (int i = 0; i < propertySymbols.Count; i++)
            {
                var propertySymbol = propertySymbols[i];
                var propertyid     = $"{propertySymbol.Type.ToPrettyString()}_{propertySymbol.Name}";

                if (propertyIdSet.Contains(propertyid))
                {
                    propertySymbols.RemoveAt(i--);
                    continue;
                }

                propertyIdSet.Add(propertyid);
            }

            return(propertySymbols);
        }
Пример #2
0
        private IEnumerable <IMethodSymbol> GetMethodSymbols()
        {
            var allInterfaces = NamedTypeSymbol.GetAllInterfacesIncludingThis();
            var allMembers    = allInterfaces.SelectMany(nts => nts.GetMembers());

            return(allMembers.OfType <IMethodSymbol>()
                   .Where(m => m.MethodKind != MethodKind.PropertyGet && m.MethodKind != MethodKind.PropertySet));
        }