protected override BinaryAnalyzerContext CreateContext()

in src/BinSkim.Driver/AnalyzeCommand.cs [33:69]


        protected override BinaryAnalyzerContext CreateContext(AnalyzeOptions options, IAnalysisLogger logger, RuntimeConditions runtimeErrors, PropertiesDictionary policy = null, string filePath = null)
        {
            BinaryAnalyzerContext binaryAnalyzerContext = base.CreateContext(options, logger, runtimeErrors, policy, filePath);

            binaryAnalyzerContext.SymbolPath = options.SymbolsPath;
            binaryAnalyzerContext.IgnorePdbLoadError = options.IgnorePdbLoadError;
            binaryAnalyzerContext.TracePdbLoads = options.Traces.Contains(nameof(Traces.PdbLoad));
            binaryAnalyzerContext.LocalSymbolDirectories = options.LocalSymbolDirectories;

#pragma warning disable CS0618 // Type or member is obsolete
            if (options.Verbose && ShouldWarnVerbose)
#pragma warning restore CS0618 // Type or member is obsolete
            {
                Warnings.LogObsoleteOption(binaryAnalyzerContext, "--verbose", Sdk.SdkResources.Verbose_ReplaceWithLevelAndKind);
                ShouldWarnVerbose = false;
            }

            if (binaryAnalyzerContext.Policy != null)
            {
                bool isRule4001Enabled = (binaryAnalyzerContext.Policy.TryGetValue("BA4001.ReportPECompilerData.Options", out object rule4001)
                    && rule4001 is PropertiesDictionary property4001
                    && property4001.TryGetValue("RuleEnabled", out object rule4001Value)
                    && rule4001Value.ToString() == "Error");
                bool isRule4002Enabled = (binaryAnalyzerContext.Policy.TryGetValue("BA4002.ReportDwarfCompilerData.Options", out object rule4002)
                    && rule4002 is PropertiesDictionary property4002
                    && property4002.TryGetValue("RuleEnabled", out object rule4002Value)
                    && rule4002Value.ToString() == "Error");

                if (isRule4001Enabled || isRule4002Enabled)
                {
                    binaryAnalyzerContext.CompilerDataLogger = new CompilerDataLogger(binaryAnalyzerContext,
                                                                                      options.TargetFileSpecifiers);
                }
            }

            return binaryAnalyzerContext;
        }