コード例 #1
0
        private void TestMatch(
            string displayName1,
            string displayName2,
            AssemblyIdentityComparer.ComparisonResult match,
            AssemblyIdentityComparer.ComparisonResult? fusionMatch = null,
            bool ignoreVersion = false,
            bool partial = false,
            bool unificationApplied = false,
            bool? fusionUnificationApplied = null,
            string policyPath = null)
        {
            if (fusionMatch == null)
            {
                fusionMatch = match;
            }

            using (var fusionPolicy = policyPath != null ? FusionAssemblyPortabilityPolicy.LoadFromFile(policyPath) : null)
            {
                var comparer = DesktopAssemblyIdentityComparer.Default;

                var policy = default(AssemblyPortabilityPolicy);
                if (policyPath != null)
                {
                    using (var policyStream = new FileStream(policyPath, FileMode.Open, FileAccess.Read))
                    {
                        policy = AssemblyPortabilityPolicy.LoadFromXml(policyStream);
                        comparer = new DesktopAssemblyIdentityComparer(policy);
                    }
                }

                bool fusionUnificationApplied1;
                var fusionResult1 = FusionAssemblyIdentityComparer.CompareAssemblyIdentity(displayName1, displayName2, ignoreVersion, policy: fusionPolicy, unificationApplied: out fusionUnificationApplied1);
                Assert.Equal(fusionMatch, fusionResult1);
                Assert.Equal(fusionUnificationApplied ?? unificationApplied, fusionUnificationApplied1);

                AssemblyIdentity id1, id2;
                AssemblyIdentityParts parts1, parts2;

                Assert.True(AssemblyIdentity.TryParseDisplayName(displayName1, out id1, out parts1));
                Assert.Equal(partial, !AssemblyIdentity.IsFullName(parts1));

                Assert.True(AssemblyIdentity.TryParseDisplayName(displayName2, out id2, out parts2));
                Assert.True(AssemblyIdentity.IsFullName(parts2), "Expected full name");

                bool unificationApplied1;
                var actual1 = comparer.Compare(null, displayName1, id2, out unificationApplied1, ignoreVersion);
                Assert.Equal(match, actual1);
                Assert.Equal(unificationApplied, unificationApplied1);

                if (!partial && id1 != null)
                {
                    bool unificationApplied2;
                    var actual2 = comparer.Compare(id1, null, id2, out unificationApplied2, ignoreVersion);
                    Assert.Equal(match, actual2);
                    Assert.Equal(unificationApplied, unificationApplied2);
                }
            }
        }
コード例 #2
0
        private static CSharpCompilationOptions CreateCSharpCompilationOptions()
        {
            string moduleName                        = null;
            string mainTypeName                      = null;
            string scriptClassName                   = null;
            IEnumerable <string> usings              = null;
            OptimizationLevel    optimizationLevel   = OptimizationLevel.Debug;
            bool   checkOverflow                     = false;
            bool   allowUnsafe                       = false;
            string cryptoKeyContainer                = null;
            string cryptoKeyFile                     = null;
            ImmutableArray <byte> cryptoPublicKey    = default(ImmutableArray <byte>);
            bool?            delaySign               = null;
            Platform         platform                = 0;
            ReportDiagnostic generalDiagnosticOption = 0;
            int warningLevel = 0;
            IEnumerable <KeyValuePair <string, ReportDiagnostic> > specificDiagnosticOptions = null;
            bool                      concurrentBuild                  = false;
            bool                      deterministic                    = false;
            DateTime                  currentLocalTime                 = default(DateTime);
            bool                      debugPlusMode                    = false;
            XmlReferenceResolver      xmlReferenceResolver             = new XmlFileResolver(null);
            SourceReferenceResolver   sourceReferenceResolver          = new SourceFileResolver(ImmutableArray <string> .Empty, null);
            SyntaxTreeOptionsProvider syntaxTreeOptionsProvider        = null;
            MetadataReferenceResolver metadataReferenceResolver        = new MetadataReferenceResolverWithEquality();
            AssemblyIdentityComparer  assemblyIdentityComparer         = AssemblyIdentityComparer.Default;  // Currently uses reference equality
            StrongNameProvider        strongNameProvider               = new DesktopStrongNameProvider();
            MetadataImportOptions     metadataImportOptions            = 0;
            bool                      referencesSupersedeLowerVersions = false;
            bool                      reportSuppressedDiagnostics      = false;
            var topLevelBinderFlags = BinderFlags.None;
            var publicSign          = false;
            NullableContextOptions nullableContextOptions = NullableContextOptions.Disable;

            return(new CSharpCompilationOptions(OutputKind.ConsoleApplication,
                                                reportSuppressedDiagnostics, moduleName, mainTypeName, scriptClassName, usings,
                                                optimizationLevel, checkOverflow, allowUnsafe, cryptoKeyContainer, cryptoKeyFile,
                                                cryptoPublicKey, delaySign, platform, generalDiagnosticOption, warningLevel,
                                                specificDiagnosticOptions, concurrentBuild, deterministic, currentLocalTime,
                                                debugPlusMode, xmlReferenceResolver, sourceReferenceResolver,
                                                syntaxTreeOptionsProvider, metadataReferenceResolver, assemblyIdentityComparer,
                                                strongNameProvider, metadataImportOptions, referencesSupersedeLowerVersions,
                                                publicSign, topLevelBinderFlags, nullableContextOptions));
        }
コード例 #3
0
 public CSharpCompilationOptions(
     OutputKind outputKind,
     bool reportSuppressedDiagnostics,
     string moduleName,
     string mainTypeName,
     string scriptClassName,
     IEnumerable <string> usings,
     OptimizationLevel optimizationLevel,
     bool checkOverflow,
     bool allowUnsafe,
     string cryptoKeyContainer,
     string cryptoKeyFile,
     ImmutableArray <byte> cryptoPublicKey,
     bool?delaySign,
     Platform platform,
     ReportDiagnostic generalDiagnosticOption,
     int warningLevel,
     IEnumerable <KeyValuePair <string, ReportDiagnostic> > specificDiagnosticOptions,
     bool concurrentBuild,
     bool deterministic,
     XmlReferenceResolver xmlReferenceResolver,
     SourceReferenceResolver sourceReferenceResolver,
     MetadataReferenceResolver metadataReferenceResolver,
     AssemblyIdentityComparer assemblyIdentityComparer,
     StrongNameProvider strongNameProvider)
     : this(outputKind, false, moduleName, mainTypeName, scriptClassName, usings, optimizationLevel,
            checkOverflow, allowUnsafe, cryptoKeyContainer, cryptoKeyFile, cryptoPublicKey,
            delaySign, platform, generalDiagnosticOption, warningLevel,
            specificDiagnosticOptions, concurrentBuild,
            deterministic : deterministic,
            currentLocalTime : default(DateTime),
            debugPlusMode : false,
            xmlReferenceResolver : xmlReferenceResolver,
            sourceReferenceResolver : sourceReferenceResolver,
            metadataReferenceResolver : metadataReferenceResolver,
            assemblyIdentityComparer : assemblyIdentityComparer,
            strongNameProvider : strongNameProvider,
            metadataImportOptions : MetadataImportOptions.Public,
            referencesSupersedeLowerVersions : false,
            publicSign : false,
            topLevelBinderFlags : BinderFlags.None,
            nullable : null)
 {
 }
コード例 #4
0
 // Defaults correspond to the compiler's defaults or indicate that the user did not specify when that is significant.
 // That's significant when one option depends on another's setting. SubsystemVersion depends on Platform and Target.
 public LanguageCompilationOptions(
     Language language,
     OutputKind outputKind,
     bool reportSuppressedDiagnostics = false,
     string moduleName                   = null,
     string mainTypeName                 = null,
     string scriptClassName              = null,
     IEnumerable <string> usings         = null,
     OptimizationLevel optimizationLevel = OptimizationLevel.Debug,
     bool checkOverflow                  = false,
     bool allowUnsafe                      = false,
     string cryptoKeyContainer             = null,
     string cryptoKeyFile                  = null,
     ImmutableArray <byte> cryptoPublicKey = default(ImmutableArray <byte>),
     bool?delaySign    = null,
     Platform platform = Platform.AnyCpu,
     ReportDiagnostic generalDiagnosticOption = ReportDiagnostic.Default,
     int warningLevel = 4,
     IEnumerable <KeyValuePair <string, ReportDiagnostic> > specificDiagnosticOptions = null,
     bool concurrentBuild      = true,
     bool deterministic        = false,
     DateTime currentLocalTime = default(DateTime),
     bool debugPlusMode        = false,
     XmlReferenceResolver xmlReferenceResolver           = null,
     SourceReferenceResolver sourceReferenceResolver     = null,
     MetadataReferenceResolver metadataReferenceResolver = null,
     AssemblyIdentityComparer assemblyIdentityComparer   = null,
     StrongNameProvider strongNameProvider = null,
     bool publicSign = false,
     MetadataImportOptions metadataImportOptions = MetadataImportOptions.Public,
     bool referencesSupersedeLowerVersions       = false,
     BinderFlags topLevelBinderFlags             = null)
     : base(outputKind, reportSuppressedDiagnostics, moduleName, mainTypeName, scriptClassName,
            cryptoKeyContainer, cryptoKeyFile, cryptoPublicKey, delaySign, publicSign, optimizationLevel, checkOverflow,
            platform, generalDiagnosticOption, warningLevel, specificDiagnosticOptions.ToImmutableDictionaryOrEmpty(),
            concurrentBuild, deterministic, currentLocalTime, debugPlusMode, xmlReferenceResolver,
            sourceReferenceResolver, metadataReferenceResolver, assemblyIdentityComparer,
            strongNameProvider, metadataImportOptions, referencesSupersedeLowerVersions)
 {
     _language                = language;
     this.Usings              = usings.AsImmutableOrEmpty();
     this.AllowUnsafe         = allowUnsafe;
     this.TopLevelBinderFlags = topLevelBinderFlags ?? BinderFlags.None;
 }
コード例 #5
0
 // Defaults correspond to the compiler's defaults or indicate that the user did not specify when that is significant.
 // That's significant when one option depends on another's setting. SubsystemVersion depends on Platform and Target.
 public CSharpCompilationOptions(
     OutputKind outputKind,
     bool reportSuppressedDiagnostics = false,
     string moduleName                   = null,
     string mainTypeName                 = null,
     string scriptClassName              = null,
     IEnumerable <string> usings         = null,
     OptimizationLevel optimizationLevel = OptimizationLevel.Debug,
     bool checkOverflow                  = false,
     bool allowUnsafe                      = false,
     string cryptoKeyContainer             = null,
     string cryptoKeyFile                  = null,
     ImmutableArray <byte> cryptoPublicKey = default(ImmutableArray <byte>),
     bool?delaySign    = null,
     Platform platform = Platform.AnyCpu,
     ReportDiagnostic generalDiagnosticOption = ReportDiagnostic.Default,
     int warningLevel = 4,
     IEnumerable <KeyValuePair <string, ReportDiagnostic> > specificDiagnosticOptions = null,
     bool concurrentBuild = true,
     bool deterministic   = false,
     XmlReferenceResolver xmlReferenceResolver           = null,
     SourceReferenceResolver sourceReferenceResolver     = null,
     MetadataReferenceResolver metadataReferenceResolver = null,
     AssemblyIdentityComparer assemblyIdentityComparer   = null,
     StrongNameProvider strongNameProvider = null,
     bool publicSign = false)
     : this(outputKind, reportSuppressedDiagnostics, moduleName, mainTypeName, scriptClassName,
            usings, optimizationLevel, checkOverflow, allowUnsafe,
            cryptoKeyContainer, cryptoKeyFile, cryptoPublicKey, delaySign, platform,
            generalDiagnosticOption, warningLevel,
            specificDiagnosticOptions, concurrentBuild, deterministic,
            extendedCustomDebugInformation : true,
            debugPlusMode : false,
            xmlReferenceResolver : xmlReferenceResolver,
            sourceReferenceResolver : sourceReferenceResolver,
            metadataReferenceResolver : metadataReferenceResolver,
            assemblyIdentityComparer : assemblyIdentityComparer,
            strongNameProvider : strongNameProvider,
            metadataImportOptions : MetadataImportOptions.Public,
            referencesSupersedeLowerVersions : false,
            publicSign : publicSign,
            topLevelBinderFlags : BinderFlags.None)
 {
 }
コード例 #6
0
        public static CompilationSettings ToCompilationSettings(this ICompilerOptions compilerOptions,
                                                                FrameworkName targetFramework)
        {
            var options = GetCompilationOptions(compilerOptions);

            // Disable 1702 until roslyn turns this off by default
            options = options.WithSpecificDiagnosticOptions(new Dictionary <string, ReportDiagnostic>
            {
                { "CS1702", ReportDiagnostic.Suppress },
                { "CS1705", ReportDiagnostic.Suppress }
            });

            if (PlatformHelper.IsMono)
            {
                options = options.WithConcurrentBuild(concurrentBuild: false);
            }

            AssemblyIdentityComparer assemblyIdentityComparer =
#if ASPNET50
                IsDesktop(targetFramework) ?
                DesktopAssemblyIdentityComparer.Default :
#endif
                null;

            options = options.WithAssemblyIdentityComparer(assemblyIdentityComparer);

            LanguageVersion languageVersion;

            if (!Enum.TryParse <LanguageVersion>(value: compilerOptions.LanguageVersion,
                                                 ignoreCase: true,
                                                 result: out languageVersion))
            {
                languageVersion = LanguageVersion.CSharp6;
            }

            var settings = new CompilationSettings
            {
                LanguageVersion    = languageVersion,
                Defines            = compilerOptions.Defines ?? Enumerable.Empty <string>(),
                CompilationOptions = options
            };

            return(settings);
        }
コード例 #7
0
 // Expects correct arguments.
 internal CSharpCompilationOptions(
     OutputKind outputKind,
     bool reportSuppressedDiagnostics,
     string moduleName,
     string mainTypeName,
     string scriptClassName,
     IEnumerable <string> usings,
     OptimizationLevel optimizationLevel,
     bool checkOverflow,
     bool allowUnsafe,
     string cryptoKeyContainer,
     string cryptoKeyFile,
     ImmutableArray <byte> cryptoPublicKey,
     bool?delaySign,
     Platform platform,
     ReportDiagnostic generalDiagnosticOption,
     int warningLevel,
     IEnumerable <KeyValuePair <string, ReportDiagnostic> > specificDiagnosticOptions,
     bool concurrentBuild,
     bool deterministic,
     DateTime currentLocalTime,
     bool debugPlusMode,
     XmlReferenceResolver xmlReferenceResolver,
     SourceReferenceResolver sourceReferenceResolver,
     MetadataReferenceResolver metadataReferenceResolver,
     AssemblyIdentityComparer assemblyIdentityComparer,
     StrongNameProvider strongNameProvider,
     MetadataImportOptions metadataImportOptions,
     bool referencesSupersedeLowerVersions,
     bool publicSign,
     BinderFlags topLevelBinderFlags,
     bool?nullable)
     : base(outputKind, reportSuppressedDiagnostics, moduleName, mainTypeName, scriptClassName,
            cryptoKeyContainer, cryptoKeyFile, cryptoPublicKey, delaySign, publicSign, optimizationLevel, checkOverflow,
            platform, generalDiagnosticOption, warningLevel, specificDiagnosticOptions.ToImmutableDictionaryOrEmpty(),
            concurrentBuild, deterministic, currentLocalTime, debugPlusMode, xmlReferenceResolver,
            sourceReferenceResolver, metadataReferenceResolver, assemblyIdentityComparer,
            strongNameProvider, metadataImportOptions, referencesSupersedeLowerVersions)
 {
     this.Usings              = usings.AsImmutableOrEmpty();
     this.AllowUnsafe         = allowUnsafe;
     this.TopLevelBinderFlags = topLevelBinderFlags;
     this.Nullable            = nullable;
 }
コード例 #8
0
 // Expects correct arguments.
 internal PhpCompilationOptions(
     OutputKind outputKind,
     string baseDirectory,
     string sdkDirectory,
     bool reportSuppressedDiagnostics,
     string moduleName,
     string mainTypeName,
     string scriptClassName,
     OptimizationLevel optimizationLevel,
     bool checkOverflow,
     string cryptoKeyContainer,
     string cryptoKeyFile,
     ImmutableArray <byte> cryptoPublicKey,
     bool?delaySign,
     Platform platform,
     ReportDiagnostic generalDiagnosticOption,
     int warningLevel,
     IEnumerable <KeyValuePair <string, ReportDiagnostic> > specificDiagnosticOptions,
     bool concurrentBuild,
     bool deterministic,
     bool extendedCustomDebugInformation,
     bool debugPlusMode,
     XmlReferenceResolver xmlReferenceResolver,
     SourceReferenceResolver sourceReferenceResolver,
     MetadataReferenceResolver metadataReferenceResolver,
     AssemblyIdentityComparer assemblyIdentityComparer,
     StrongNameProvider strongNameProvider,
     MetadataImportOptions metadataImportOptions,
     bool publicSign,
     PhpDocTypes phpdocTypes,
     PhpParseOptions parseOptions)
     : base(outputKind, reportSuppressedDiagnostics, moduleName, mainTypeName, scriptClassName,
            cryptoKeyContainer, cryptoKeyFile, cryptoPublicKey, delaySign, publicSign, optimizationLevel, checkOverflow,
            platform, generalDiagnosticOption, warningLevel, specificDiagnosticOptions.ToImmutableDictionaryOrEmpty(),
            concurrentBuild, deterministic, extendedCustomDebugInformation, debugPlusMode, xmlReferenceResolver,
            sourceReferenceResolver, metadataReferenceResolver, assemblyIdentityComparer,
            strongNameProvider, metadataImportOptions)
 {
     this.BaseDirectory = baseDirectory;
     this.SdkDirectory  = sdkDirectory;
     this.PhpDocTypes   = phpdocTypes;
     this.ParseOptions  = parseOptions;
 }
コード例 #9
0
 // 15.9 BACKCOMPAT OVERLOAD -- DO NOT TOUCH
 public CSharpCompilationOptions(
     OutputKind outputKind,
     bool reportSuppressedDiagnostics,
     string moduleName,
     string mainTypeName,
     string scriptClassName,
     IEnumerable <string> usings,
     OptimizationLevel optimizationLevel,
     bool checkOverflow,
     bool allowUnsafe,
     string cryptoKeyContainer,
     string cryptoKeyFile,
     ImmutableArray <byte> cryptoPublicKey,
     bool?delaySign,
     Platform platform,
     ReportDiagnostic generalDiagnosticOption,
     int warningLevel,
     IEnumerable <KeyValuePair <string, ReportDiagnostic> > specificDiagnosticOptions,
     bool concurrentBuild,
     bool deterministic,
     XmlReferenceResolver xmlReferenceResolver,
     SourceReferenceResolver sourceReferenceResolver,
     MetadataReferenceResolver metadataReferenceResolver,
     AssemblyIdentityComparer assemblyIdentityComparer,
     StrongNameProvider strongNameProvider,
     bool publicSign,
     MetadataImportOptions metadataImportOptions)
     : this(outputKind, reportSuppressedDiagnostics, moduleName, mainTypeName, scriptClassName,
            usings, optimizationLevel, checkOverflow, allowUnsafe,
            cryptoKeyContainer, cryptoKeyFile, cryptoPublicKey, delaySign, platform,
            generalDiagnosticOption, warningLevel,
            specificDiagnosticOptions, concurrentBuild, deterministic,
            xmlReferenceResolver,
            sourceReferenceResolver,
            metadataReferenceResolver,
            assemblyIdentityComparer,
            strongNameProvider,
            publicSign,
            metadataImportOptions,
            nullableContextOptions : NullableContextOptions.Disable)
 {
 }
コード例 #10
0
        private static CompilationSettings ToCompilationSettings(CommonCompilerOptions compilerOptions,
                                                                 NuGetFramework targetFramework,
                                                                 string projectDirectory)
        {
            var options = GetCompilationOptions(compilerOptions, projectDirectory);

            // Disable 1702 until roslyn turns this off by default
            options = options.WithSpecificDiagnosticOptions(new Dictionary <string, ReportDiagnostic>
            {
                { "CS1701", ReportDiagnostic.Suppress }, // Binding redirects
                { "CS1702", ReportDiagnostic.Suppress },
                { "CS1705", ReportDiagnostic.Suppress }
            });

            AssemblyIdentityComparer assemblyIdentityComparer =
                targetFramework.IsDesktop() ?
                DesktopAssemblyIdentityComparer.Default :
                null;

            options = options.WithAssemblyIdentityComparer(assemblyIdentityComparer);

            LanguageVersion languageVersion;

            if (!Enum.TryParse <LanguageVersion>(value: compilerOptions.LanguageVersion,
                                                 ignoreCase: true,
                                                 result: out languageVersion))
            {
                languageVersion = LanguageVersion.CSharp6;
            }

            var settings = new CompilationSettings
            {
                LanguageVersion    = languageVersion,
                Defines            = compilerOptions.Defines ?? Enumerable.Empty <string>(),
                CompilationOptions = options
            };

            return(settings);
        }
コード例 #11
0
 // Expects correct arguments.
 internal CSharpCompilationOptions(
     OutputKind outputKind,
     string moduleName,
     string mainTypeName,
     string scriptClassName,
     IEnumerable <string> usings,
     bool optimize,
     bool checkOverflow,
     bool allowUnsafe,
     string cryptoKeyContainer,
     string cryptoKeyFile,
     bool?delaySign,
     int fileAlignment,
     ulong baseAddress,
     Platform platform,
     ReportDiagnostic generalDiagnosticOption,
     int warningLevel,
     IEnumerable <KeyValuePair <string, ReportDiagnostic> > specificDiagnosticOptions,
     bool highEntropyVirtualAddressSpace,
     DebugInformationKind debugInformationKind,
     SubsystemVersion subsystemVersion,
     string runtimeMetadataVersion,
     bool concurrentBuild,
     XmlReferenceResolver xmlReferenceResolver,
     SourceReferenceResolver sourceReferenceResolver,
     MetadataReferenceResolver metadataReferenceResolver,
     MetadataReferenceProvider metadataReferenceProvider,
     AssemblyIdentityComparer assemblyIdentityComparer,
     StrongNameProvider strongNameProvider,
     MetadataImportOptions metadataImportOptions,
     ImmutableArray <string> features)
     : base(outputKind, moduleName, mainTypeName, scriptClassName, cryptoKeyContainer, cryptoKeyFile, delaySign, optimize, checkOverflow, fileAlignment, baseAddress,
            platform, generalDiagnosticOption, warningLevel, specificDiagnosticOptions, highEntropyVirtualAddressSpace, debugInformationKind,
            subsystemVersion, concurrentBuild, xmlReferenceResolver, sourceReferenceResolver, metadataReferenceResolver, metadataReferenceProvider, assemblyIdentityComparer, strongNameProvider, metadataImportOptions, features)
 {
     this.Usings                 = usings.AsImmutableOrEmpty();
     this.AllowUnsafe            = allowUnsafe;
     this.RuntimeMetadataVersion = runtimeMetadataVersion;
 }
コード例 #12
0
        public CSharpCompilationOptions CreateCSharpCompilationOptions()
        {
            string moduleName                        = null;
            string mainTypeName                      = null;
            string scriptClassName                   = null;
            IEnumerable <string> usings              = null;
            OptimizationLevel    optimizationLevel   = OptimizationLevel.Debug;
            bool             checkOverflow           = false;
            bool             allowUnsafe             = false;
            string           cryptoKeyContainer      = null;
            string           cryptoKeyFile           = null;
            bool?            delaySign               = null;
            int              fileAlignment           = 0;
            ulong            baseAddress             = 0;
            Platform         platform                = 0;
            ReportDiagnostic generalDiagnosticOption = 0;
            int              warningLevel            = 0;
            IEnumerable <KeyValuePair <string, ReportDiagnostic> > specificDiagnosticOptions = null;
            bool                      highEntropyVirtualAddressSpace = false;
            SubsystemVersion          subsystemVersion          = default(SubsystemVersion);
            string                    runtimeMetadataVersion    = null;
            bool                      concurrentBuild           = false;
            XmlReferenceResolver      xmlReferenceResolver      = new XmlFileResolver(null);
            SourceReferenceResolver   sourceReferenceResolver   = new SourceFileResolver(ImmutableArray <string> .Empty, null);
            MetadataReferenceResolver metadataReferenceResolver = new MetadataFileReferenceResolver(ImmutableArray <string> .Empty, null);
            MetadataReferenceProvider metadataReferenceProvider = MetadataFileReferenceProvider.Default;    // Currently uses reference equality
            AssemblyIdentityComparer  assemblyIdentityComparer  = AssemblyIdentityComparer.Default;         // Currently uses reference equality
            StrongNameProvider        strongNameProvider        = new DesktopStrongNameProvider();
            MetadataImportOptions     metadataImportOptions     = 0;
            ImmutableArray <string>   features = ImmutableArray <string> .Empty;

            return(new CSharpCompilationOptions(OutputKind.ConsoleApplication, moduleName, mainTypeName, scriptClassName, usings,
                                                optimizationLevel, checkOverflow, allowUnsafe, cryptoKeyContainer, cryptoKeyFile, delaySign, fileAlignment, baseAddress,
                                                platform, generalDiagnosticOption, warningLevel, specificDiagnosticOptions, highEntropyVirtualAddressSpace,
                                                subsystemVersion, runtimeMetadataVersion, concurrentBuild, xmlReferenceResolver, sourceReferenceResolver, metadataReferenceResolver, metadataReferenceProvider,
                                                assemblyIdentityComparer, strongNameProvider, metadataImportOptions, features));
        }
コード例 #13
0
 // Defaults correspond to the compiler's defaults or indicate that the user did not specify when that is significant.
 // That's significant when one option depends on another's setting. SubsystemVersion depends on Platform and Target.
 public CSharpCompilationOptions(
     OutputKind outputKind,
     string moduleName,
     string mainTypeName,
     string scriptClassName,
     IEnumerable <string> usings,
     OptimizationLevel optimizationLevel,
     bool checkOverflow,
     bool allowUnsafe,
     string cryptoKeyContainer,
     string cryptoKeyFile,
     ImmutableArray <byte> cryptoPublicKey,
     bool?delaySign,
     Platform platform,
     ReportDiagnostic generalDiagnosticOption,
     int warningLevel,
     IEnumerable <KeyValuePair <string, ReportDiagnostic> > specificDiagnosticOptions,
     bool concurrentBuild,
     XmlReferenceResolver xmlReferenceResolver,
     SourceReferenceResolver sourceReferenceResolver,
     MetadataReferenceResolver metadataReferenceResolver,
     AssemblyIdentityComparer assemblyIdentityComparer,
     StrongNameProvider strongNameProvider)
     : this(outputKind, false, moduleName, mainTypeName, scriptClassName, usings, optimizationLevel, checkOverflow, allowUnsafe,
            cryptoKeyContainer, cryptoKeyFile, cryptoPublicKey, delaySign, platform, generalDiagnosticOption, warningLevel,
            specificDiagnosticOptions, concurrentBuild,
            deterministic : false,
            extendedCustomDebugInformation : true,
            debugPlusMode : false,
            xmlReferenceResolver : xmlReferenceResolver,
            sourceReferenceResolver : sourceReferenceResolver,
            metadataReferenceResolver : metadataReferenceResolver,
            assemblyIdentityComparer : assemblyIdentityComparer,
            strongNameProvider : strongNameProvider,
            metadataImportOptions : MetadataImportOptions.Public)
 {
 }
コード例 #14
0
        protected void ReadCompilationOptionsFrom(
            ObjectReader reader,
            out OutputKind outputKind,
            out bool reportSuppressedDiagnostics,
            out string moduleName,
            out string mainTypeName,
            out string scriptClassName,
            out OptimizationLevel optimizationLevel,
            out bool checkOverflow,
            out string cryptoKeyContainer,
            out string cryptoKeyFile,
            out ImmutableArray <byte> cryptoPublicKey,
            out bool?delaySign,
            out Platform platform,
            out ReportDiagnostic generalDiagnosticOption,
            out int warningLevel,
            out IEnumerable <KeyValuePair <string, ReportDiagnostic> > specificDiagnosticOptions,
            out bool concurrentBuild,
            out bool deterministic,
            out bool publicSign,
            out XmlReferenceResolver xmlReferenceResolver,
            out SourceReferenceResolver sourceReferenceResolver,
            out MetadataReferenceResolver metadataReferenceResolver,
            out AssemblyIdentityComparer assemblyIdentityComparer,
            out StrongNameProvider strongNameProvider,
            CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            outputKind = (OutputKind)reader.ReadInt32();
            reportSuppressedDiagnostics = reader.ReadBoolean();
            moduleName   = reader.ReadString();
            mainTypeName = reader.ReadString();

            scriptClassName   = reader.ReadString();
            optimizationLevel = (OptimizationLevel)reader.ReadInt32();
            checkOverflow     = reader.ReadBoolean();

            // REVIEW: is it okay this being not part of snapshot?
            cryptoKeyContainer = reader.ReadString();
            cryptoKeyFile      = reader.ReadString();

            cryptoPublicKey = reader.ReadArray <byte>().ToImmutableArrayOrEmpty();

            delaySign = reader.ReadBoolean() ? (bool?)reader.ReadBoolean() : null;

            platform = (Platform)reader.ReadInt32();
            generalDiagnosticOption = (ReportDiagnostic)reader.ReadInt32();

            warningLevel = reader.ReadInt32();

            // REVIEW: I don't think there is a guarantee on ordering of elements in the immutable dictionary.
            //         unfortunately, we need to sort them to make it deterministic
            //         not sure why CompilationOptions uses SequencialEqual to check options equality
            //         when ordering can change result of it even if contents are same.
            var count = reader.ReadInt32();
            List <KeyValuePair <string, ReportDiagnostic> > specificDiagnosticOptionsList = null;

            if (count > 0)
            {
                specificDiagnosticOptionsList = new List <KeyValuePair <string, ReportDiagnostic> >(count);

                for (var i = 0; i < count; i++)
                {
                    var key   = reader.ReadString();
                    var value = (ReportDiagnostic)reader.ReadInt32();

                    specificDiagnosticOptionsList.Add(KeyValuePair.Create(key, value));
                }
            }

            specificDiagnosticOptions = specificDiagnosticOptionsList ?? SpecializedCollections.EmptyEnumerable <KeyValuePair <string, ReportDiagnostic> >();

            concurrentBuild = reader.ReadBoolean();
            deterministic   = reader.ReadBoolean();
            publicSign      = reader.ReadBoolean();

            // REVIEW: What should I do with these. are these service required when compilation is built ourselves, not through
            //         compiler.
            xmlReferenceResolver      = XmlFileResolver.Default;
            sourceReferenceResolver   = SourceFileResolver.Default;
            metadataReferenceResolver = null;
            assemblyIdentityComparer  = DesktopAssemblyIdentityComparer.Default;
            strongNameProvider        = new DesktopStrongNameProvider();
        }
コード例 #15
0
 public new MetaCompilationOptions WithAssemblyIdentityComparer(AssemblyIdentityComparer comparer) => (MetaCompilationOptions)base.WithAssemblyIdentityComparer(comparer);
コード例 #16
0
ファイル: CompilationContext.cs プロジェクト: rgani/roslyn
        private static int IndexOfMatchingAssembly(AssemblyIdentity referenceIdentity, ImmutableArray<Symbol> assembliesAndModules, AssemblyIdentityComparer assemblyIdentityComparer)
        {
            for (int i = 0; i < assembliesAndModules.Length; i++)
            {
                var assembly = assembliesAndModules[i] as AssemblySymbol;
                if (assembly != null && assemblyIdentityComparer.ReferenceMatchesDefinition(referenceIdentity, assembly.Identity))
                {
                    return i;
                }
            }

            return -1;
        }
コード例 #17
0
 internal CompilationOptionsAdapter(OutputKind outputKind, bool reportSuppressedDiagnostics, string moduleName, string mainTypeName, string scriptClassName, string cryptoKeyContainer, string cryptoKeyFile, ImmutableArray <byte> cryptoPublicKey, bool?delaySign, bool publicSign, OptimizationLevel optimizationLevel, bool checkOverflow, Platform platform, ReportDiagnostic generalDiagnosticOption, int warningLevel, ImmutableDictionary <string, ReportDiagnostic> specificDiagnosticOptions, bool concurrentBuild, bool deterministic, DateTime currentLocalTime, bool debugPlusMode, XmlReferenceResolver xmlReferenceResolver, SourceReferenceResolver sourceReferenceResolver, MetadataReferenceResolver metadataReferenceResolver, AssemblyIdentityComparer assemblyIdentityComparer, StrongNameProvider strongNameProvider, MetadataImportOptions metadataImportOptions, bool referencesSupersedeLowerVersions)
     : base(outputKind, reportSuppressedDiagnostics, moduleName, mainTypeName, scriptClassName, cryptoKeyContainer, cryptoKeyFile, cryptoPublicKey, delaySign, publicSign, optimizationLevel, checkOverflow, platform, generalDiagnosticOption, warningLevel, specificDiagnosticOptions, concurrentBuild, deterministic, currentLocalTime, debugPlusMode, xmlReferenceResolver, sourceReferenceResolver, metadataReferenceResolver, assemblyIdentityComparer, strongNameProvider, metadataImportOptions, referencesSupersedeLowerVersions)
 {
 }
コード例 #18
0
ファイル: MetadataUtilities.cs プロジェクト: rgani/roslyn
        /// <summary>
        /// Remove any modules that are not in the set of referenced modules.
        /// If there are duplicates of referenced modules, potentially differing by
        /// version, one instance of the highest version is kept and others dropped.
        /// </summary>
        /// <remarks>
        /// Binding against this reduced set of modules will not handle certain valid cases
        /// where binding to full set would succeed (e.g.: binding to types outside the
        /// referenced modules). And since duplicates are dropped, this will prevent resolving
        /// ambiguities between two versions of the same assembly by using aliases. Also,
        /// there is no attempt here to follow binding redirects or to use the CLR to determine
        /// which version of an assembly to prefer when there are duplicate assemblies.
        /// </remarks>
        private static void RemoveUnreferencedModules(
            ArrayBuilder<MetadataReference> modules,
            ArrayBuilder<AssemblyIdentity> identities,
            AssemblyIdentityComparer identityComparer,
            ArrayBuilder<AssemblyIdentity> referencedModules)
        {
            Debug.Assert(modules.Count == identities.Count);

            var referencedIndices = PooledHashSet<int>.GetInstance();

            int n = identities.Count;
            int index;
            foreach (var referencedModule in referencedModules)
            {
                index = -1;
                for (int i = 0; i < n; i++)
                {
                    var identity = identities[i];
                    var compareResult = identityComparer.Compare(referencedModule, identity);
                    switch (compareResult)
                    {
                        case AssemblyIdentityComparer.ComparisonResult.NotEquivalent:
                            break;
                        case AssemblyIdentityComparer.ComparisonResult.Equivalent:
                        case AssemblyIdentityComparer.ComparisonResult.EquivalentIgnoringVersion:
                            if ((index < 0) || (identity.Version > identities[index].Version))
                            {
                                index = i;
                            }
                            break;
                        default:
                            throw ExceptionUtilities.UnexpectedValue(compareResult);
                    }
                }
                if (index >= 0)
                {
                    referencedIndices.Add(index);
                }
            }

            Debug.Assert(referencedIndices.Count <= modules.Count);
            Debug.Assert(referencedIndices.Count <= referencedModules.Count);

            index = 0;
            for (int i = 0; i < n; i++)
            {
                if (referencedIndices.Contains(i))
                {
                    modules[index] = modules[i];
                    index++;
                }
            }
            modules.Clip(index);

            referencedIndices.Free();
        }
コード例 #19
0
 protected override CompilationOptions CommonWithAssemblyIdentityComparer(AssemblyIdentityComparer comparer)
 {
     return(WithAssemblyIdentityComparer(comparer));
 }
コード例 #20
0
        /// <summary>
        /// Group module metadata into assemblies.
        /// If <paramref name="moduleVersionId"/> is set, the
        /// assemblies are limited to those referenced by that module.
        /// </summary>
        internal static ImmutableArray <MetadataReference> MakeAssemblyReferences(
            this ImmutableArray <MetadataBlock> metadataBlocks,
            Guid moduleVersionId,
            AssemblyIdentityComparer identityComparer)
        {
            Debug.Assert((identityComparer == null) || (moduleVersionId != default(Guid)));

            // Get metadata for each module.
            var metadataBuilder = ArrayBuilder <ModuleMetadata> .GetInstance();

            // Win8 applications contain a reference to Windows.winmd version >= 1.3
            // and perhaps multiple application winmds. At runtime, Windows.winmd
            // is replaced by multiple Windows.*.winmd version >= 1.3. In the EE, we
            // need to map compile-time assembly references to the runtime assemblies
            // supplied by the debugger. To do so, we "merge" all winmds named
            // Windows.*.winmd into a single fake Windows.winmd at runtime.
            // All other (application) winmds are left as is.
            var runtimeWinMdBuilder = ArrayBuilder <ModuleMetadata> .GetInstance();

            foreach (var block in metadataBlocks)
            {
                var metadata = ModuleMetadata.CreateFromMetadata(block.Pointer, block.Size, includeEmbeddedInteropTypes: true);
                try
                {
                    if (IsWindowsComponent(metadata.MetadataReader, metadata.Name))
                    {
                        runtimeWinMdBuilder.Add(metadata);
                    }
                    else
                    {
                        metadataBuilder.Add(metadata);
                    }
                }
                catch (Exception e) when(IsBadMetadataException(e))
                {
                    // Ignore modules with "bad" metadata.
                }
            }

            // Index non-primary netmodules by name. Multiple modules may
            // have the same name but we do not have a way to differentiate
            // netmodules other than by name so if there are duplicates, the
            // dictionary value is set to null and references are dropped when
            // generating the containing assembly metadata.
            Dictionary <string, ModuleMetadata> modulesByName = null;

            foreach (var metadata in metadataBuilder)
            {
                if (IsPrimaryModule(metadata))
                {
                    // Primary module. No need to add to dictionary.
                    continue;
                }
                if (modulesByName == null)
                {
                    modulesByName = new Dictionary <string, ModuleMetadata>(); // Requires case-insensitive comparison?
                }
                var name = metadata.Name;
                modulesByName[name] = modulesByName.ContainsKey(name) ? null : metadata;
            }

            // Build assembly references from modules in primary module manifests.
            var referencesBuilder = ArrayBuilder <MetadataReference> .GetInstance();

            var identitiesBuilder = (identityComparer == null) ? null : ArrayBuilder <AssemblyIdentity> .GetInstance();

            AssemblyIdentity corLibrary         = null;
            AssemblyIdentity intrinsicsAssembly = null;

            foreach (var metadata in metadataBuilder)
            {
                if (!IsPrimaryModule(metadata))
                {
                    continue;
                }
                if (identitiesBuilder != null)
                {
                    var reader   = metadata.MetadataReader;
                    var identity = reader.ReadAssemblyIdentityOrThrow();
                    identitiesBuilder.Add(identity);
                    // If this assembly has no references, and declares
                    // System.Object, assume it is the COR library.
                    if ((corLibrary == null) &&
                        (reader.AssemblyReferences.Count == 0) &&
                        reader.DeclaresTheObjectClass())
                    {
                        corLibrary = identity;
                    }
                    else if ((intrinsicsAssembly == null) &&
                             reader.DeclaresType((r, t) => r.IsPublicNonInterfaceType(t, ExpressionCompilerConstants.IntrinsicAssemblyNamespace, ExpressionCompilerConstants.IntrinsicAssemblyTypeName)))
                    {
                        intrinsicsAssembly = identity;
                    }
                }
                var reference = MakeAssemblyMetadata(metadata, modulesByName);
                referencesBuilder.Add(reference);
            }

            if (identitiesBuilder != null)
            {
                // Remove assemblies not directly referenced by the target module.
                var module = metadataBuilder.FirstOrDefault(m => m.MetadataReader.GetModuleVersionIdOrThrow() == moduleVersionId);
                Debug.Assert(module != null);
                if (module != null)
                {
                    var referencedModules = ArrayBuilder <AssemblyIdentity> .GetInstance();

                    referencedModules.Add(module.MetadataReader.ReadAssemblyIdentityOrThrow());
                    referencedModules.AddRange(module.MetadataReader.GetReferencedAssembliesOrThrow());
                    // Ensure COR library is included, otherwise any compilation will fail.
                    // (Note, an equivalent assembly may have already been included from
                    // GetReferencedAssembliesOrThrow above but RemoveUnreferencedModules
                    // allows duplicates.)
                    Debug.Assert(corLibrary != null);
                    if (corLibrary != null)
                    {
                        referencedModules.Add(corLibrary);
                    }
                    // Ensure Debugger intrinsic methods assembly is included.
                    if (intrinsicsAssembly != null)
                    {
                        referencedModules.Add(intrinsicsAssembly);
                    }
                    RemoveUnreferencedModules(referencesBuilder, identitiesBuilder, identityComparer, referencedModules);
                    referencedModules.Free();
                }
                identitiesBuilder.Free();
            }

            metadataBuilder.Free();

            // Any runtime winmd modules were separated out initially. Now add
            // those to a placeholder for the missing compile time module since
            // each of the runtime winmds refer to the compile time module.
            if (runtimeWinMdBuilder.Any())
            {
                referencesBuilder.Add(MakeCompileTimeWinMdAssemblyMetadata(runtimeWinMdBuilder));
            }

            runtimeWinMdBuilder.Free();
            return(referencesBuilder.ToImmutableAndFree());
        }
コード例 #21
0
 /// <summary>
 /// Group module metadata into assemblies.
 /// If <paramref name="moduleVersionId"/> is set, the
 /// assemblies are limited to those referenced by that module.
 /// </summary>
 internal static ImmutableArray <MetadataReference> MakeAssemblyReferences(
     this ImmutableArray <MetadataBlock> metadataBlocks,
     Guid moduleVersionId,
     AssemblyIdentityComparer identityComparer,
     MakeAssemblyReferencesKind kind,
     out IReadOnlyDictionary <
コード例 #22
0
ファイル: MetadataUtilities.cs プロジェクト: rgani/roslyn
        /// <summary>
        /// Group module metadata into assemblies.
        /// If <paramref name="moduleVersionId"/> is set, the
        /// assemblies are limited to those referenced by that module.
        /// </summary>
        internal static ImmutableArray<MetadataReference> MakeAssemblyReferences(
            this ImmutableArray<MetadataBlock> metadataBlocks,
            Guid moduleVersionId,
            AssemblyIdentityComparer identityComparer)
        {
            Debug.Assert((identityComparer == null) || (moduleVersionId != default(Guid)));

            // Get metadata for each module.
            var metadataBuilder = ArrayBuilder<ModuleMetadata>.GetInstance();
            // Win8 applications contain a reference to Windows.winmd version >= 1.3
            // and perhaps multiple application winmds. At runtime, Windows.winmd
            // is replaced by multiple Windows.*.winmd version >= 1.3. In the EE, we
            // need to map compile-time assembly references to the runtime assemblies
            // supplied by the debugger. To do so, we "merge" all winmds named
            // Windows.*.winmd into a single fake Windows.winmd at runtime.
            // All other (application) winmds are left as is.
            var runtimeWinMdBuilder = ArrayBuilder<ModuleMetadata>.GetInstance();
            foreach (var block in metadataBlocks)
            {
                var metadata = ModuleMetadata.CreateFromMetadata(block.Pointer, block.Size, includeEmbeddedInteropTypes: true);
                try
                {
                    if (IsWindowsComponent(metadata.MetadataReader, metadata.Name))
                    {
                        runtimeWinMdBuilder.Add(metadata);
                    }
                    else
                    {
                        metadataBuilder.Add(metadata);
                    }
                }
                catch (Exception e) when (IsBadMetadataException(e))
                {
                    // Ignore modules with "bad" metadata.
                }
            }

            // Index non-primary netmodules by name. Multiple modules may
            // have the same name but we do not have a way to differentiate
            // netmodules other than by name so if there are duplicates, the
            // dictionary value is set to null and references are dropped when
            // generating the containing assembly metadata.
            Dictionary<string, ModuleMetadata> modulesByName = null;
            foreach (var metadata in metadataBuilder)
            {
                if (IsPrimaryModule(metadata))
                {
                    // Primary module. No need to add to dictionary.
                    continue;
                }
                if (modulesByName == null)
                {
                    modulesByName = new Dictionary<string, ModuleMetadata>(); // Requires case-insensitive comparison?
                }
                var name = metadata.Name;
                modulesByName[name] = modulesByName.ContainsKey(name) ? null : metadata;
            }

            // Build assembly references from modules in primary module manifests.
            var referencesBuilder = ArrayBuilder<MetadataReference>.GetInstance();
            var identitiesBuilder = (identityComparer == null) ? null : ArrayBuilder<AssemblyIdentity>.GetInstance();
            AssemblyIdentity corLibrary = null;
            AssemblyIdentity intrinsicsAssembly = null;

            foreach (var metadata in metadataBuilder)
            {
                if (!IsPrimaryModule(metadata))
                {
                    continue;
                }
                if (identitiesBuilder != null)
                {
                    var reader = metadata.MetadataReader;
                    var identity = reader.ReadAssemblyIdentityOrThrow();
                    identitiesBuilder.Add(identity);
                    // If this assembly has no references, and declares
                    // System.Object, assume it is the COR library.
                    if ((corLibrary == null) &&
                        (reader.AssemblyReferences.Count == 0) &&
                        reader.DeclaresTheObjectClass())
                    {
                        corLibrary = identity;
                    }
                    else if ((intrinsicsAssembly == null) &&
                        reader.DeclaresType((r, t) => r.IsPublicNonInterfaceType(t, ExpressionCompilerConstants.IntrinsicAssemblyNamespace, ExpressionCompilerConstants.IntrinsicAssemblyTypeName)))
                    {
                        intrinsicsAssembly = identity;
                    }
                }
                var reference = MakeAssemblyMetadata(metadata, modulesByName);
                referencesBuilder.Add(reference);
            }

            if (identitiesBuilder != null)
            {
                // Remove assemblies not directly referenced by the target module.
                var module = metadataBuilder.FirstOrDefault(m => m.MetadataReader.GetModuleVersionIdOrThrow() == moduleVersionId);
                Debug.Assert(module != null);
                if (module != null)
                {
                    var referencedModules = ArrayBuilder<AssemblyIdentity>.GetInstance();
                    referencedModules.Add(module.MetadataReader.ReadAssemblyIdentityOrThrow());
                    referencedModules.AddRange(module.MetadataReader.GetReferencedAssembliesOrThrow());
                    // Ensure COR library is included, otherwise any compilation will fail.
                    // (Note, an equivalent assembly may have already been included from
                    // GetReferencedAssembliesOrThrow above but RemoveUnreferencedModules
                    // allows duplicates.)
                    Debug.Assert(corLibrary != null);
                    if (corLibrary != null)
                    {
                        referencedModules.Add(corLibrary);
                    }
                    // Ensure Debugger intrinsic methods assembly is included.
                    if (intrinsicsAssembly != null)
                    {
                        referencedModules.Add(intrinsicsAssembly);
                    }
                    RemoveUnreferencedModules(referencesBuilder, identitiesBuilder, identityComparer, referencedModules);
                    referencedModules.Free();
                }
                identitiesBuilder.Free();
            }

            metadataBuilder.Free();

            // Any runtime winmd modules were separated out initially. Now add
            // those to a placeholder for the missing compile time module since
            // each of the runtime winmds refer to the compile time module.
            if (runtimeWinMdBuilder.Any())
            {
                referencesBuilder.Add(MakeCompileTimeWinMdAssemblyMetadata(runtimeWinMdBuilder));
            }

            runtimeWinMdBuilder.Free();
            return referencesBuilder.ToImmutableAndFree();
        }
コード例 #23
0
ファイル: ExternAliasRecord.cs プロジェクト: jbe2277/roslyn
 /// <remarks>
 /// <paramref name="assemblyIdentityComparer"/> is only here to make the call
 /// pattern uniform - it's actually only used by one subtype.
 /// </remarks>
 public abstract int GetIndexOfTargetAssembly <TSymbol>(
     ImmutableArray <TSymbol> assembliesAndModules,
     AssemblyIdentityComparer assemblyIdentityComparer)
     where TSymbol : class, ISymbol;
コード例 #24
0
 protected override CompilationOptions CommonWithAssemblyIdentityComparer(AssemblyIdentityComparer comparer) =>
     WithAssemblyIdentityComparer(comparer);
コード例 #25
0
        protected void ReadCompilationOptionsFrom(
            ObjectReader reader,
            out OutputKind outputKind,
            out bool reportSuppressedDiagnostics,
            out string moduleName,
            out string mainTypeName,
            out string scriptClassName,
            out OptimizationLevel optimizationLevel,
            out bool checkOverflow,
            out string cryptoKeyContainer,
            out string cryptoKeyFile,
            out ImmutableArray<byte> cryptoPublicKey,
            out bool? delaySign,
            out Platform platform,
            out ReportDiagnostic generalDiagnosticOption,
            out int warningLevel,
            out IEnumerable<KeyValuePair<string, ReportDiagnostic>> specificDiagnosticOptions,
            out bool concurrentBuild,
            out bool deterministic,
            out bool publicSign,
            out XmlReferenceResolver xmlReferenceResolver,
            out SourceReferenceResolver sourceReferenceResolver,
            out MetadataReferenceResolver metadataReferenceResolver,
            out AssemblyIdentityComparer assemblyIdentityComparer,
            out StrongNameProvider strongNameProvider,
            CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            outputKind = (OutputKind)reader.ReadInt32();
            reportSuppressedDiagnostics = reader.ReadBoolean();
            moduleName = reader.ReadString();
            mainTypeName = reader.ReadString();

            scriptClassName = reader.ReadString();
            optimizationLevel = (OptimizationLevel)reader.ReadInt32();
            checkOverflow = reader.ReadBoolean();

            // REVIEW: is it okay this being not part of snapshot?
            cryptoKeyContainer = reader.ReadString();
            cryptoKeyFile = reader.ReadString();

            cryptoPublicKey = reader.ReadArray<byte>().ToImmutableArrayOrEmpty();

            delaySign = reader.ReadBoolean() ? (bool?)reader.ReadBoolean() : null;

            platform = (Platform)reader.ReadInt32();
            generalDiagnosticOption = (ReportDiagnostic)reader.ReadInt32();

            warningLevel = reader.ReadInt32();

            // REVIEW: I don't think there is a guarantee on ordering of elements in the immutable dictionary.
            //         unfortunately, we need to sort them to make it deterministic
            //         not sure why CompilationOptions uses SequencialEqual to check options equality
            //         when ordering can change result of it even if contents are same.
            var count = reader.ReadInt32();
            List<KeyValuePair<string, ReportDiagnostic>> specificDiagnosticOptionsList = null;

            if (count > 0)
            {
                specificDiagnosticOptionsList = new List<KeyValuePair<string, ReportDiagnostic>>(count);

                for (var i = 0; i < count; i++)
                {
                    var key = reader.ReadString();
                    var value = (ReportDiagnostic)reader.ReadInt32();

                    specificDiagnosticOptionsList.Add(KeyValuePair.Create(key, value));
                }
            }

            specificDiagnosticOptions = specificDiagnosticOptionsList ?? SpecializedCollections.EmptyEnumerable<KeyValuePair<string, ReportDiagnostic>>();

            concurrentBuild = reader.ReadBoolean();
            deterministic = reader.ReadBoolean();
            publicSign = reader.ReadBoolean();

            // REVIEW: What should I do with these. are these service required when compilation is built ourselves, not through
            //         compiler.
            xmlReferenceResolver = XmlFileResolver.Default;
            sourceReferenceResolver = SourceFileResolver.Default;
            metadataReferenceResolver = null;
            assemblyIdentityComparer = DesktopAssemblyIdentityComparer.Default;
            strongNameProvider = new DesktopStrongNameProvider();
        }