Beispiel #1
0
        static void Main(string[] args)
        {
            if (ParseCommandLineArgs(args))
            {
                var ws       = MSBuildWorkspace.Create();
                var solution = ws.OpenSolutionAsync(_solutionPath).Result;

                //add reference to xamarin.ios.dll
                foreach (var project in solution.Projects)
                {
                    solution = solution.AddMetadataReference(project.Id, MetadataReference.CreateFromFile(_xamAsm.Location));
                }

                //loop through all projects
                foreach (var project in solution.Projects)
                {
                    Console.WriteLine("Analyzing project {0}", project.Name);
                    var compilation = project.GetCompilationAsync().Result;

                    foreach (var tree in compilation.SyntaxTrees)
                    {
                        var model = compilation.GetSemanticModel(tree);

                        var nsobjects = new NSObjectSubclassAnalyzer(tree, model)
                        {
                            Availability = _availability, NsObject = _nsobject, Platform = _platform, SdkVersion = _sdkVersion.Value
                        };
                        nsobjects.Analyze();
                        nsobjects.OutputDeprecatedApiWarnings(Console.Out);

                        var variables = new VariableDeclarationAnalyzer(tree, model)
                        {
                            Availability = _availability, NsObject = _nsobject, Platform = _platform, SdkVersion = _sdkVersion.Value
                        };
                        variables.Analyze();
                        variables.OutputDeprecatedApiWarnings(Console.Out);

                        var invocations = new MemberInvocationAnalyzer(tree, model)
                        {
                            Availability = _availability, NsObject = _nsobject, Platform = _platform, SdkVersion = _sdkVersion.Value
                        };
                        invocations.Analyze();
                        invocations.OutputDeprecatedApiWarnings(Console.Out);

                        var identifiers = new IdentifierAnalyzer(tree, model)
                        {
                            Availability = _availability, NsObject = _nsobject, Platform = _platform, SdkVersion = _sdkVersion.Value
                        };
                        identifiers.Analyze();

                        //this last analyzer picks up a lot of symbols already caught by the previous 2
                        //let's get rid of some duplicates if we can
                        identifiers.RemoveDuplicates(invocations.DeprecatedElements);
                        identifiers.RemoveDuplicates(variables.DeprecatedElements);
                        identifiers.OutputDeprecatedApiWarnings(Console.Out);
                    }
                }
            }
        }
        static void Main(string[] args)
        {
            if (ParseCommandLineArgs(args))
            {
                var ws = MSBuildWorkspace.Create();
                var solution = ws.OpenSolutionAsync(_solutionPath).Result;

                //add reference to xamarin.ios.dll 
                foreach (var project in solution.Projects)
                    solution = solution.AddMetadataReference(project.Id, MetadataReference.CreateFromFile(_xamAsm.Location));

                //loop through all projects
                foreach (var project in solution.Projects)
                {
                    Console.WriteLine("Analyzing project {0}", project.Name);
                    var compilation = project.GetCompilationAsync().Result;

                    foreach (var tree in compilation.SyntaxTrees)
                    {
                        var model = compilation.GetSemanticModel(tree);

                        var nsobjects = new NSObjectSubclassAnalyzer(tree, model) { Availability = _availability, NsObject = _nsobject, Platform = _platform, SdkVersion = _sdkVersion.Value };
                        nsobjects.Analyze();
                        nsobjects.OutputDeprecatedApiWarnings(Console.Out);

                        var variables = new VariableDeclarationAnalyzer(tree, model) { Availability = _availability, NsObject = _nsobject, Platform = _platform, SdkVersion = _sdkVersion.Value };
                        variables.Analyze();
                        variables.OutputDeprecatedApiWarnings(Console.Out);

                        var invocations = new MemberInvocationAnalyzer(tree, model) { Availability = _availability, NsObject = _nsobject, Platform = _platform, SdkVersion = _sdkVersion.Value };
                        invocations.Analyze();
                        invocations.OutputDeprecatedApiWarnings(Console.Out);

                        var identifiers = new IdentifierAnalyzer(tree, model) { Availability = _availability, NsObject = _nsobject, Platform = _platform, SdkVersion = _sdkVersion.Value };
                        identifiers.Analyze();

                        //this last analyzer picks up a lot of symbols already caught by the previous 2
                        //let's get rid of some duplicates if we can
                        identifiers.RemoveDuplicates(invocations.DeprecatedElements);
                        identifiers.RemoveDuplicates(variables.DeprecatedElements);
                        identifiers.OutputDeprecatedApiWarnings(Console.Out);
                    }
                }
            }
        }