public void NoPIATypeSubstitutionForClassThatImplementNoPiaInterface()
        {
            //Check type substitution when a class implement a PIA interface

            var localConsumer = CreateEmptyCompilation(
                assemblyName: "Dummy",
                source: CSharpTestSource.None,
                references: new List <MetadataReference>()
            {
                TestReferences.SymbolsTests.NoPia.GeneralPia,
                TestReferences.SymbolsTests.NoPia.ExternalAsm1
            }
                );

            var localConsumerRefsAsm = localConsumer.Assembly.GetNoPiaResolutionAssemblies();
            var canonicalType        = localConsumerRefsAsm
                                       .First(arg => arg.Name == "GeneralPia")
                                       .GlobalNamespace.GetTypeMembers("ISubFuncProp")
                                       .Single();

            NamedTypeSymbol classRefLocalType = localConsumerRefsAsm
                                                .First(arg => arg.Name == "ExternalAsm1")
                                                .GlobalNamespace.GetTypeMembers("SubFuncProp")
                                                .Single();
            MethodSymbol methodSymbol = classRefLocalType
                                        .GetMembers("Foo")
                                        .OfType <MethodSymbol>()
                                        .Single();
            var interfaceType = classRefLocalType.GetDeclaredInterfaces(null).First();

            Assert.Same(canonicalType, interfaceType);
            Assert.IsAssignableFrom <PENamedTypeSymbol>(interfaceType);
        }
Пример #2
0
        internal override ImmutableArray <NamedTypeSymbol> GetDeclaredInterfaces(ConsList <Symbol> basesBeingResolved)
        {
            if (_lazyDeclaredInterfaces.IsDefault)
            {
                var underlyingBaseInterfaces = _underlyingType.GetDeclaredInterfaces(basesBeingResolved);
                var result = this.RetargetingTranslator.Retarget(underlyingBaseInterfaces);
                ImmutableInterlocked.InterlockedCompareExchange(ref _lazyDeclaredInterfaces, result, default(ImmutableArray <NamedTypeSymbol>));
            }

            return(_lazyDeclaredInterfaces);
        }