public void TestSampleMetadataGeneration() { var policy = new SingleFileMetadataPolicy(); var sampleMetadataModule = _context.GetModuleForSimpleName("SampleMetadataAssembly"); var transformResult = MetadataTransform.Run(policy, new[] { _systemModule, sampleMetadataModule }); Assert.Equal(2, transformResult.Scopes.Count); var systemScope = transformResult.Scopes.Single(s => s.Name.Value == "PrimaryMetadataAssembly"); var sampleScope = transformResult.Scopes.Single(s => s.Name.Value == "SampleMetadataAssembly"); Assert.Equal(_systemModule.GetAllTypes().Count(t => !policy.IsBlocked(t)), systemScope.GetAllTypes().Count()); Assert.Equal(sampleMetadataModule.GetAllTypes().Count(t => !policy.IsBlocked(t)), sampleScope.GetAllTypes().Count()); // TODO: check individual types }
public void TestExplicitScopeAttributesForWinRTSingleFilePolicy() { // Test that custom attributes referring to blocked types don't show up in metadata var sampleMetadataModule = _context.GetModuleForSimpleName("SampleMetadataAssembly"); var sampleWinRTMetadataModule = _context.GetModuleForSimpleName("SampleWinRTMetadataAssembly"); var windowsWinRTMetadataModule = _context.GetModuleForSimpleName("WindowsWinRTMetadataAssembly"); Cts.MetadataType controlType = windowsWinRTMetadataModule.GetType("Windows", "Control"); Cts.MetadataType derivedFromControl = sampleWinRTMetadataModule.GetType("SampleMetadataWinRT", "DerivedFromControl"); Cts.MetadataType derivedFromControlInCustomScope = sampleWinRTMetadataModule.GetType("SampleMetadataWinRT", "DerivedFromControlAndInCustomScope"); var policy = new SingleFileMetadataPolicy(); var transformResult = MetadataTransform.Run(policy, new[] { _systemModule, sampleMetadataModule, sampleWinRTMetadataModule, windowsWinRTMetadataModule }); var controlTypeMetadata = transformResult.GetTransformedTypeDefinition(controlType); var derivedFromControlMetadata = transformResult.GetTransformedTypeDefinition(derivedFromControl); var derivedFromControlInCustomScopeMetadata = transformResult.GetTransformedTypeDefinition(derivedFromControlInCustomScope); CheckTypeDefinitionForProperWinRTHome(controlTypeMetadata, "Windows"); ScopeDefinition scopeDefOfDerivedFromControlType = GetScopeDefinitionOfType(derivedFromControlMetadata); Assert.Equal("SampleWinRTMetadataAssembly", scopeDefOfDerivedFromControlType.Name.Value); CheckTypeDefinitionForProperWinRTHome(derivedFromControlInCustomScopeMetadata, "SampleMetadataWinRT"); }