Skip to content

Commit 3918418

Browse files
committed
Exclude csproj files from student files in csharp exercises
1 parent b277e66 commit 3918418

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

crates/plugins/csharp/src/policy.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,14 @@ impl StudentFilePolicy for CSharpStudentFilePolicy {
3434
&self.project_config
3535
}
3636

37-
// false for files in bin or obj directories, true for other files in src.
37+
// false for .csproj files and files in bin or obj directories
38+
// true for files in src except for .csproj files
3839
fn is_non_extra_student_file(&self, path: &Path) -> bool {
39-
path.starts_with("src") && !Self::is_child_of_binary_dir(path)
40+
path.starts_with("src")
41+
// exclude files in bin
42+
&& !Self::is_child_of_binary_dir(path)
43+
// exclude .csproj files
44+
&& !path.extension().map(|ext| ext == "csproj").unwrap_or_default()
4045
}
4146
}
4247

@@ -57,4 +62,10 @@ mod test {
5762
assert!(policy.is_student_file(Path::new("src/file")));
5863
assert!(policy.is_student_file(Path::new("src/any/file")));
5964
}
65+
66+
#[test]
67+
fn csproj_is_not_student_file() {
68+
let policy = CSharpStudentFilePolicy::new(Path::new(".")).unwrap();
69+
assert!(!policy.is_student_file(Path::new("src/Project.csproj")));
70+
}
6071
}

0 commit comments

Comments
 (0)