コード例 #1
0
ファイル: DeadCodeEliminationTest.cs プロジェクト: x335/JSIL
        protected string GetJavascriptWithDCE(string fileName, string expectedText = null)
        {
            var dce = new DeadCodeAnalyzer();
            var analyzerSettings = new Dictionary<string, object>
            {
                {"DeadCodeElimination", true},
                {"NonAggressiveVirtualMethodElimination", false},
                {"WhiteList", new List<string> {@"System\.Void Program::Main\(.*\)"}}
            };
            dce.SetConfiguration(analyzerSettings);

            var defaultConfiguration = MakeConfiguration();
            var generatedJs = GetJavascript(
                Path.Combine(@"..\Tests.DCE", fileName),
                expectedText,
                makeConfiguration: () => defaultConfiguration,
                initializeTranslator: (translator) =>
                {
                    translator.AssembliesLoaded += dce.AddAssemblies;
                    translator.AnalyzeStarted += () => dce.Analyze(translator._TypeInfoProvider);
                    translator.MemberCanBeSkipped += dce.MemberCanBeSkipped;
                });

            return generatedJs;
        }
コード例 #2
0
        protected string GetJavascriptWithDCE(string fileName, string expectedText = null)
        {
            var dce = new DeadCodeAnalyzer();
            var analyzerSettings = new Dictionary<string, object>
            {
                {"DeadCodeElimination", true},
                {"NonAggressiveVirtualMethodElimination", false},
                {"WhiteList", new List<string> {@"System\.Void Program::Main\(.*\)"}}
            };
            dce.SetConfiguration(analyzerSettings);

            var defaultConfiguration = MakeConfiguration();
            var generatedJs = GetJavascript(
                Path.Combine(@"..\Tests.DCE", fileName),
                expectedText,
                makeConfiguration: () => defaultConfiguration,
                analyzers: new[] { dce }
            );

            return generatedJs;
        }