コード例 #1
0
        private string GenerateNotSupportedAssemblyForSourceFile(string sourceFile)
        {
            string[]   apiExclusions;
            SyntaxTree syntaxTree;

            try
            {
                syntaxTree = CSharpSyntaxTree.ParseText(File.ReadAllText(sourceFile));
            }
            catch (Exception ex)
            {
                Log.LogError(ex.Message);
                return(null);
            }

            if (string.IsNullOrEmpty(ApiExclusionListPath) || !File.Exists(ApiExclusionListPath))
            {
                apiExclusions = null;
            }
            else
            {
                apiExclusions = File.ReadAllLines(ApiExclusionListPath);
            }
            var        rewriter = new NotSupportedAssemblyRewriter(Message, apiExclusions);
            SyntaxNode root     = rewriter.Visit(syntaxTree.GetRoot());

            return(root.GetText().ToString());
        }
コード例 #2
0
        private void GenerateNotSupportedAssemblyForSourceFile(string sourceFile, string outputPath, string[] apiExclusions)
        {
            SyntaxTree syntaxTree;

            try
            {
                LanguageVersion languageVersion = LanguageVersion.Default;
                if (!String.IsNullOrEmpty(LangVersion) && !LanguageVersionFacts.TryParse(LangVersion, out languageVersion))
                {
                    Log.LogError($"Invalid LangVersion value '{LangVersion}'");
                    return;
                }
                syntaxTree = CSharpSyntaxTree.ParseText(File.ReadAllText(sourceFile), new CSharpParseOptions(languageVersion));
            }
            catch (Exception ex)
            {
                Log.LogErrorFromException(ex, false);
                return;
            }

            var        rewriter = new NotSupportedAssemblyRewriter(Message, apiExclusions);
            SyntaxNode root     = rewriter.Visit(syntaxTree.GetRoot());
            string     text     = root.GetText().ToString();

            File.WriteAllText(outputPath, text);
        }
コード例 #3
0
        private void GenerateNotSupportedAssemblyForSourceFile(string sourceFile, string outputPath, string[] apiExclusions)
        {
            SyntaxTree syntaxTree;

            try
            {
                syntaxTree = CSharpSyntaxTree.ParseText(File.ReadAllText(sourceFile));
            }
            catch (Exception ex)
            {
                Log.LogErrorFromException(ex, false);
                return;
            }

            var        rewriter = new NotSupportedAssemblyRewriter(Message, apiExclusions);
            SyntaxNode root     = rewriter.Visit(syntaxTree.GetRoot());
            string     text     = root.GetText().ToString();

            File.WriteAllText(outputPath, text);
        }