Cci.IDefinition Cci.IReference.AsDefinition(CodeAnalysis.Emit.Context context) { return(null); }
Cci.IAssemblyReference Cci.IModuleReference.GetContainingAssembly(CodeAnalysis.Emit.Context context) { return(this); }
IEnumerable <Cci.ICustomAttribute> Cci.IReference.GetAttributes(CodeAnalysis.Emit.Context context) { return(SpecializedCollections.EmptyEnumerable <Cci.ICustomAttribute>()); }
public void AssemblyRefs_DuplicateRows() { var compilation = CreateCompilationWithMscorlib( "class C : C1 { }; class D { }", new[] { TestReferences.SymbolsTests.Methods.CSMethods }); PEAssemblyBuilder assembly = new PEAssemblyBuilder( (SourceAssemblySymbol)compilation.Assembly, null, compilation.Options.OutputKind, GetDefaultModulePropertiesForSerialization(), Enumerable.Empty<ResourceDescription>(), // map all references to a single name: assembylSymbol => new AssemblyIdentity("foo") ); // Don't attempt to emit if there were any syntax, declaration, semantic, or emitted errors previously. DiagnosticBag diagnostics = new DiagnosticBag(); Compiler.CompileMethodBodies(compilation, assembly, false, false, null, null, null, diagnostics, default(CancellationToken)); diagnostics.Verify(); var context = new CodeAnalysis.Emit.Context(assembly, null, new DiagnosticBag()); ImmutableArray<byte> image; using (var stream = new MemoryStream()) { Cci.PeWriter.WritePeToStream(context, compilation.MessageProvider, stream, CancellationToken.None); image = stream.ToImmutable(); } context.Diagnostics.Verify(); // check that there are no duplicate rows in AssemblyRef table: PEAssembly emittedAssembly = AssemblyMetadata.CreateFromImage(image).Assembly; var emittedReferences = emittedAssembly.Modules[0].ReferencedAssemblies; Assert.Equal(1, emittedReferences.Length); Assert.Equal("foo", emittedReferences[0].Name); }