// Gets a list of all of our delegates used by the HAL
        public static List<HALDelegateClass> GetDelegates()
        {
            List<HALDelegateClass> halBaseMethods = new List<HALDelegateClass>();
            var p = Path.DirectorySeparatorChar;
            var file = $"..{p}..{p}NetworkTablesCore{p}Native{p}Interop.cs";
            HALDelegateClass cs = new HALDelegateClass
            {
                ClassName = "",
                Methods = new List<DelegateDeclarationSyntax>()
            };
            using (var stream = File.OpenRead(file))
            {
                var tree = CSharpSyntaxTree.ParseText(SourceText.From(stream), path: file);
                cs.ClassName = Path.GetFileName(file);
                var methods =
                    tree.GetRoot()
                        .DescendantNodes()
                        .OfType<DelegateDeclarationSyntax>()
                        .Select(a => a).ToList();
                cs.Methods.AddRange(methods);
            }
            halBaseMethods.Add(cs);

            return halBaseMethods;
        }
Exemple #2
0
        // Gets a list of all of our delegates used by the HAL
        public static List <HALDelegateClass> GetDelegates()
        {
            List <HALDelegateClass> halBaseMethods = new List <HALDelegateClass>();

            var pathToSolution = FindRootSolutionDirectory();
            var p = Path.DirectorySeparatorChar;

            Assert.That(pathToSolution, Is.Not.Null);
            var file            = $"{pathToSolution}{p}src{p}FRC.NetworkTables.Core{p}Native{p}Interop.cs";
            HALDelegateClass cs = new HALDelegateClass
            {
                ClassName = "",
                Methods   = new List <DelegateDeclarationSyntax>()
            };

            using (var stream = File.OpenRead(file))
            {
                var tree = CSharpSyntaxTree.ParseText(SourceText.From(stream), path: file);
                cs.ClassName = Path.GetFileName(file);
                var methods =
                    tree.GetRoot()
                    .DescendantNodes()
                    .OfType <DelegateDeclarationSyntax>()
                    .Select(a => a).ToList();
                cs.Methods.AddRange(methods);
            }
            halBaseMethods.Add(cs);

            return(halBaseMethods);
        }