-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle vb syntax when doing file analyze (#201)
- Loading branch information
Showing
2 changed files
with
110 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Codelyzer.Analysis.Build; | ||
using Microsoft.CodeAnalysis.CSharp; | ||
using Microsoft.CodeAnalysis.VisualBasic; | ||
using Microsoft.Extensions.Logging.Abstractions; | ||
using NUnit.Framework; | ||
|
||
namespace Codelyzer.Analysis.Tests | ||
{ | ||
public class FileBuildHandlerTests | ||
{ | ||
[Test] | ||
public void TestCsharpFileBuildHandler() | ||
{ | ||
var projectPath = "test.csproj"; | ||
var testFile = $@" | ||
using System; | ||
namespace Test | ||
{{ | ||
public class TestClass {{}} | ||
}}"; | ||
var fileInfo = new Dictionary<string, string> | ||
{ | ||
{"TestFile.cs", testFile} | ||
}; | ||
var fileBuildHandler = new FileBuildHandler(NullLogger.Instance, projectPath, fileInfo, new List<string>(), new List<string>()); | ||
var result= fileBuildHandler.Build().Result; | ||
Assert.IsTrue(result.Count == 1); | ||
Assert.IsTrue(result.First().SyntaxTree is CSharpSyntaxTree); | ||
} | ||
|
||
[Test] | ||
public void TestVisualBasicFileBuildHandler() | ||
{ | ||
var projectPath = "test.vbproj"; | ||
var testFile = $@" | ||
Class TestClass | ||
Public Sub Main() | ||
Console.WriteLine(1) | ||
End Sub | ||
End Class"; | ||
var fileInfo = new Dictionary<string, string> | ||
{ | ||
{"TestFile.vb", testFile} | ||
}; | ||
var fileBuildHandler = new FileBuildHandler(NullLogger.Instance, projectPath, fileInfo, new List<string>(), new List<string>()); | ||
var result= fileBuildHandler.Build().Result; | ||
Assert.IsTrue(result.Count == 1); | ||
Assert.IsTrue(result.First().SyntaxTree is VisualBasicSyntaxTree); | ||
} | ||
|
||
} | ||
} |