Esempio n. 1
0
        private async Task <QuickFixResponse> FindDiagnostics(string contents, bool includeFileName)
        {
            using (var testProject = await TestAssets.Instance.GetTestProjectAsync("CakeProject", shadowCopy: false))
                using (var host = CreateOmniSharpHost(testProject.Directory))
                {
                    var testFile = new TestFile(Path.Combine(testProject.Directory, "build.cake"), contents);

                    var request = new CodeCheckRequest
                    {
                        FileName = includeFileName ? testFile.FileName : string.Empty,
                    };

                    var updateBufferRequest = new UpdateBufferRequest
                    {
                        Buffer   = testFile.Content.Code,
                        Column   = request.Column,
                        FileName = testFile.FileName,
                        Line     = request.Line,
                        FromDisk = false
                    };

                    await GetUpdateBufferHandler(host).Handle(updateBufferRequest);

                    var requestHandler = GetRequestHandler(host);

                    return(await requestHandler.Handle(request));
                }
        }
Esempio n. 2
0
        public async Task Handles_Misc_File_Deletion()
        {
            //When the file is deleted the diagnostics must not be returned
            using (var testProject = await TestAssets.Instance.GetTestProjectAsync("EmptyProject"))
            {
                var testfile = new TestFile("a.cs", "class C { b a = new b(); int n  }");
                using (var host = CreateOmniSharpHost(testProject.Directory))
                {
                    var filePath = await AddTestFile(host, testProject, testfile);

                    var request = new CodeCheckRequest()
                    {
                        FileName = filePath
                    };
                    var actual = await host.GetResponse <CodeCheckRequest, QuickFixResponse>(OmniSharpEndpoints.CodeCheck, request);

                    Assert.Single(actual.QuickFixes);

                    await WaitForFileUpdate(filePath, host, FileWatching.FileChangeType.Delete);

                    actual = await host.GetResponse <CodeCheckRequest, QuickFixResponse>(OmniSharpEndpoints.CodeCheck, request);

                    Assert.Empty(actual.QuickFixes);
                }
            }
        }
Esempio n. 3
0
        private static async Task <QuickFixResponse> GetCodeChecksync(OmniSharpTestHost host, string filePath)
        {
            CodeCheckService service = host.GetCodeCheckServiceService();

            var request = new CodeCheckRequest {
                FileName = filePath
            };

            return(await service.Handle(request));
        }
        public static async Task <QuickFixResponse> RequestCodeCheckAsync(this OmniSharpTestHost host, string filePath)
        {
            var service = host.GetCodeCheckService();

            var request = new CodeCheckRequest {
                FileName = filePath
            };

            return(await service.Handle(request));
        }
Esempio n. 5
0
        public async Task Adds_Misc_Document_Which_Supports_Only_syntactic_diagnostics()
        {
            using (var testProject = await TestAssets.Instance.GetTestProjectAsync("EmptyProject"))
            {
                var testfile = new TestFile("a.cs", "class C { b a = new b(); int n  }");
                using (var host = CreateOmniSharpHost(testProject.Directory))
                {
                    var filePath = await AddTestFile(host, testProject, testfile);

                    var request = new CodeCheckRequest()
                    {
                        FileName = filePath
                    };
                    var actual = await host.GetResponse <CodeCheckRequest, QuickFixResponse>(OmniSharpEndpoints.CodeCheck, request);

                    Assert.Single(actual.QuickFixes);
                    Assert.Equal("; expected", actual.QuickFixes.First().Text);
                }
            }
        }