diff --git a/src/modules/dotnet.rs b/src/modules/dotnet.rs index 592bd59e6..2c0169ba0 100644 --- a/src/modules/dotnet.rs +++ b/src/modules/dotnet.rs @@ -19,11 +19,20 @@ const PROJECT_JSON_FILE: &str = "project.json"; /// the current directory: /// global.json, project.json, *.sln, *.csproj, *.fsproj, *.xproj pub fn module<'a>(context: &'a Context) -> Option> { - let dotnet_files = get_local_dotnet_files(context).ok()?; - if dotnet_files.is_empty() { + // First check if this is a DotNet Project before doing the O(n) + // check for the version using the JSON files + let is_dotnet_project = context + .try_begin_scan()? + .set_files(&[GLOBAL_JSON_FILE, PROJECT_JSON_FILE]) + .set_extensions(&["sln", "csproj", "fsproj", "xproj"]) + .is_match(); + + if !is_dotnet_project { return None; } + let dotnet_files = get_local_dotnet_files(context).ok()?; + let mut module = context.new_module("dotnet"); let config = DotnetConfig::try_load(module.config);