Ejemplo n.º 1
0
 public ISymbol GetWrapperMemberSymbolByName(string wrapperMemberName)
 {
     return(ImplementableSymbols.GetImplementableSymbolByName(wrapperMemberName));
 }
Ejemplo n.º 2
0
        protected void SetFromSymbols
        (
            INamedTypeSymbol typeToImplSymbol,
            INamedTypeSymbol implementorSymbol
        )
        {
            this.TypeToImplementSymbol = typeToImplSymbol;
            this.ImplementorTypeSymbol = implementorSymbol.GetNoTypeForNull(TheCompilation);

            if (TypeToImplementSymbol.IsClass() &&
                (ImplementorTypeSymbol?.IsClass() == true))
            {
                throw new Exception($"Roxy Usage Error: Both TypeToImplement '{TypeToImplementSymbol.Name}' and Implementor '{implementorSymbol.Name}' cannot be classes.");
            }

            this.ClassName = TypeToImplementSymbol.GetClassName(this.ClassName);

            IEnumerable <OverrideVirtualAttribute> overrideVirtualAttrs =
                ImplementorTypeSymbol.GetAttrObjects <OverrideVirtualAttribute>();

            foreach (OverrideVirtualAttribute overrideVirtualAttr in overrideVirtualAttrs)
            {
                SetOverrideVirtualMembers(overrideVirtualAttr.IncludeBase, overrideVirtualAttr.MemberNames);
            }

            IEnumerable <IPropertySymbol> pluginProps =
                ImplementorTypeSymbol
                .GetAllMembers()
                .GetItemsOfType <ISymbol, IPropertySymbol>();


            // at this point there is a rule that shared plugins should
            // precede those that share them within the implementor interface/class
            foreach (IPropertySymbol prop in pluginProps)
            {
                PluginAttribute pluginAttr = prop.GetAttrObject <PluginAttribute>();

                if (pluginAttr == null)
                {
                    continue;
                }

                PluginInfo pluginInfo =
                    new PluginInfo
                    (
                        this.TheCore,
                        prop,
                        pluginAttr.ImplementorType?.GetTypeSymbol(this.TheCompilation),
                        pluginAttr.InitType?.GetTypeSymbol(this.TheCompilation),
                        _sharedPluginInfos);

                if (pluginAttr.IsShared)
                {
                    _sharedPluginInfos.Add(pluginInfo);
                }
                else
                {
                    _nonSharedPluginInfos.Add(pluginInfo);
                }
            }

            SetImplementableSymbols();

            PluginInfos?.DoForEach(pluginInfo => pluginInfo.SetMaps(ImplementableSymbols));

            // this should be here - otherwise AttrsMultiConcersRoxyTest is breaking.
            //remove plugins from ImplementableSymbols
            ImplementableSymbols = ImplementableSymbols.Except
                                   (
                PluginInfos.Select(pI => pI.PluginPropSymbol),
                RoslynAnalysisAndGenerationUtils.TheSymbolByNameAndSignatureComparer
                                   );

            SetMemberSymbols();
        }