дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 09:41:34 +02:00
perf(run): skip dependency and build directories in .NET detection (#8135)
.NET run configuration detection walked dependency and build trees (Python venvs, CocoaPods, Xcode DerivedData, SwiftPM checkouts, out/) looking for project files. These directories are now skipped, case-insensitively, alongside bin/obj/node_modules/target/build/dist/vendor/packages. Detection stays complete: there is no depth or directory budget, so deeply nested projects without a solution near the root are still found (covered by a new test). Co-authored-by: dengliu <[email protected]>
Цей коміт міститься в:
1 джерело
8a301dad86
коміт
cd92df2007
2 files changed
+53
-26
No files matched your search
@@ -10,44 +10,57 @@ use std::{
|
||||
path::Path,
|
||||
};
|
||||
|
||||
fn is_skipped_dir(name: &str) -> bool {
|
||||
let lower = name.to_ascii_lowercase();
|
||||
lower.starts_with('.')
|
||||
|| matches!(
|
||||
lower.as_str(),
|
||||
"bin"
|
||||
| "obj"
|
||||
| "node_modules"
|
||||
| "target"
|
||||
| "build"
|
||||
| "dist"
|
||||
| "vendor"
|
||||
| "packages"
|
||||
| "out"
|
||||
| "venv"
|
||||
| "__pycache__"
|
||||
| "sourcepackages"
|
||||
| "pods"
|
||||
| "carthage"
|
||||
| "deriveddata"
|
||||
)
|
||||
|| ide_workspace::unreal::GENERATED_DIRS.iter().any(|dir| dir.eq_ignore_ascii_case(&lower))
|
||||
}
|
||||
|
||||
pub(crate) fn detect(root: &Path, out: &mut Vec<RunConfig>) {
|
||||
let mut dirs = vec![root.to_path_buf()];
|
||||
let mut projects = BTreeSet::new();
|
||||
while let Some(dir) = dirs.pop() {
|
||||
let Ok(entries) = fs::read_dir(&dir) else { continue };
|
||||
for entry in entries.flatten() {
|
||||
let path = entry.path();
|
||||
let name = entry.file_name().to_string_lossy().into_owned();
|
||||
if entry.file_type().is_ok_and(|t| t.is_dir()) {
|
||||
let Ok(file_type) = entry.file_type() else { continue };
|
||||
let file_name = entry.file_name();
|
||||
if file_type.is_dir() {
|
||||
// Case-insensitive: Unreal's generated trees (`Binaries`, `Intermediate`, …) hold
|
||||
// tens of thousands of files and copies of the engine's own tool projects.
|
||||
let lower = name.to_ascii_lowercase();
|
||||
if !lower.starts_with('.')
|
||||
&& !matches!(
|
||||
lower.as_str(),
|
||||
"bin" | "obj" | "node_modules" | "target" | "build" | "dist" | "vendor" | "packages"
|
||||
)
|
||||
&& !ide_workspace::unreal::GENERATED_DIRS.iter().any(|dir| dir.eq_ignore_ascii_case(&lower))
|
||||
{
|
||||
dirs.push(path);
|
||||
if !is_skipped_dir(&file_name.to_string_lossy()) {
|
||||
dirs.push(entry.path());
|
||||
}
|
||||
} else if entry.file_type().is_ok_and(|t| t.is_file()) {
|
||||
if is_project_file(&path) {
|
||||
projects.insert(path);
|
||||
} else if file_type.is_file() {
|
||||
let name_path = Path::new(&file_name);
|
||||
if is_project_file(name_path) {
|
||||
projects.insert(entry.path());
|
||||
continue;
|
||||
}
|
||||
match path.extension().and_then(|e| e.to_str()).unwrap_or_default().to_ascii_lowercase().as_str() {
|
||||
"sln" | "slnx" => {
|
||||
if let Ok(src) = fs::read_to_string(&path) {
|
||||
for project in solution_projects(
|
||||
&src,
|
||||
path.extension().is_some_and(|e| e.eq_ignore_ascii_case("slnx")),
|
||||
) {
|
||||
projects.insert(dir.join(project));
|
||||
}
|
||||
}
|
||||
let Some(ext) = name_path.extension().and_then(|e| e.to_str()) else { continue };
|
||||
if (ext.eq_ignore_ascii_case("sln") || ext.eq_ignore_ascii_case("slnx"))
|
||||
&& let Ok(src) = fs::read_to_string(entry.path())
|
||||
{
|
||||
for project in solution_projects(&src, ext.eq_ignore_ascii_case("slnx")) {
|
||||
projects.insert(dir.join(project));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,3 +284,17 @@ fn mixed_solutions_with_spaces_and_non_ascii_paths() {
|
||||
names.sort_unstable();
|
||||
assert_eq!(names, ["Cs (.NET Project)", "Vb App (.NET Project)", "应用 (.NET Project)"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn detection_skips_dependency_and_build_trees_without_dropping_deep_projects() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let root = temp.path();
|
||||
// Deeply nested project without a solution near the root is still discovered.
|
||||
write(root, "services/billing/api/src/Billing.Api/Billing.Api.csproj", CONSOLE);
|
||||
for skipped in ["venv", "VENV", "__pycache__", "out", "Pods", "Carthage", "SourcePackages", "DerivedData"] {
|
||||
write(root, &format!("{skipped}/Ignored.csproj"), CONSOLE);
|
||||
}
|
||||
let configs = detect(root);
|
||||
let projects: Vec<&str> = configs.iter().map(|c| c.extras.params["project"].as_str()).collect();
|
||||
assert_eq!(projects, ["services/billing/api/src/Billing.Api/Billing.Api.csproj"]);
|
||||
}
|
||||
Reference in new issue
Заблокувати користувача