-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
优化 HE 输出以及修复 依赖库无法发出通知的 BUG #343
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ public static class VSCSharpProjectInfomation | |
public static readonly HashSet<string> ExpectFiles; | ||
public static readonly bool EnableImplicitUsings; | ||
public static IEnumerable<string>? MainAssemblyUsings; | ||
public static readonly string HEOutputPath; | ||
static VSCSharpProjectInfomation() | ||
{ | ||
ExpectFiles = []; | ||
|
@@ -29,6 +30,7 @@ static VSCSharpProjectInfomation() | |
ExecutePath = new FileInfo(currentExeFilePath).Directory!.FullName; | ||
var currentDirectoryInfo = new DirectoryInfo(ExecutePath); | ||
MainCsprojPath = FindFileDirectory(currentDirectoryInfo,"*.csproj"); | ||
HEOutputPath = Path.Combine(MainCsprojPath, "HEOutput"); | ||
var files = Directory.GetFiles(MainCsprojPath,"*.csproj"); | ||
CSProjFilePath = files[0]; | ||
BinPath = Path.Combine(MainCsprojPath, "bin"); | ||
|
@@ -93,9 +95,13 @@ public static bool CheckFileAvailiable(string file) | |
return CheckFileAvivaliable(file, BinPath, ObjPath); | ||
} | ||
|
||
public static bool IsXamlAndResxFile(string file) | ||
{ | ||
return file.EndsWith(".xaml") || file.EndsWith(".resx"); | ||
} | ||
Comment on lines
+98
to
+101
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tip Codebase Verification Improve the The current implementation does not account for different casing or additional extensions. Consider using
Analysis chainVerify the correctness of file type check. The method ensures that the file extension is either Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify the correctness of file type check.
# Test: Search for the method usage. Expect: Proper handling of XAML and RESX file types.
rg --type cs 'IsXamlAndResxFile'
Length of output: 844 Script: #!/bin/bash
# Extract the code snippets from VSCSharpMainFileWatcher.cs where IsXamlAndResxFile method is used
# Search for the method usage and display 5 lines of context around each match
rg --type cs 'IsXamlAndResxFile' -A 5 -B 5 src/Natasha.CSharp/Extension/HotExecutor/Natasha.CSharp.HotExecutor/Component/WatcherUtils/VSCSharpMainFileWatcher.cs
Length of output: 1284 Script: #!/bin/bash
# Verify the correctness of file type check in IsXamlAndResxFile method by testing edge cases
# Create a temporary C# file to test the method
cat <<EOF > /tmp/TestIsXamlAndResxFile.cs
using System;
public class Test
{
public static bool IsXamlAndResxFile(string file)
{
return file.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase) || file.EndsWith(".resx", StringComparison.OrdinalIgnoreCase);
}
public static void Main()
{
string[] testFiles = {
"file.xaml",
"file.resx",
"file.XAML",
"file.RESX",
"file.xaml.bak",
"file.resx.bak",
"file.xaml?version=1",
"file.resx?version=1"
};
foreach (var file in testFiles)
{
Console.WriteLine($"\{file}: {IsXamlAndResxFile(file)}");
}
}
}
EOF
# Compile and run the temporary C# file
mcs /tmp/TestIsXamlAndResxFile.cs -out:/tmp/TestIsXamlAndResxFile.exe
mono /tmp/TestIsXamlAndResxFile.exe
Length of output: 260 Script: #!/bin/bash
# Search for the IsXamlAndResxFile method definition and its usage in the repository
# Find the method definition
rg --type cs 'public static bool IsXamlAndResxFile' -A 10
# Find all usages of the IsXamlAndResxFile method
rg --type cs 'IsXamlAndResxFile'
Length of output: 2481 |
||
public static bool CheckFileAvivaliable(string file, string binPath, string objPath) | ||
{ | ||
if (file.EndsWith(".cs") || file.EndsWith(".xaml") || file.EndsWith(".resx")) | ||
if (file.EndsWith(".cs")) | ||
{ | ||
if (file.StartsWith(binPath)) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Codebase Verification
Issues found in file deletion logic.
The file deletion logic does not explicitly handle edge cases such as read-only files, hidden files, or files in use. This could lead to incomplete deletion of files in the output path.
src/Natasha.CSharp/Extension/HotExecutor/Natasha.CSharp.HotExecutor.SG/HotExecutorGenerator.cs
: File deletion logic at line 25.Analysis chain
Verify the correctness of file deletion logic.
The changes ensure that all files in the output path are deleted before creating a new logger. Verify that the deletion logic handles all edge cases and does not leave any files undeleted.
Verify the robustness of file deletion logic.
The changes ensure that all files in the output path are deleted before creating a new logger. Verify that the deletion logic correctly handles edge cases such as read-only files, hidden files, or files in use.
Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 1930
Script:
Length of output: 805