Skip to content

Commit

Permalink
Fix dotnet sln project type
Browse files Browse the repository at this point in the history
The presence of an "src/" directory doesn't say anything about the
type of the project. This commit fixes the dotnet sln project type to
rely on the presence of an .sln file instead of the "src/" directory.
  • Loading branch information
DamienCassou committed Oct 29, 2024
1 parent 0a15d81 commit 8714de5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
## master (unreleased)

* [#1910](https://github.com/bbatsov/projectile/pull/1910): Reverts [#1895](https://github.com/bbatsov/projectile/pull/1895) as those changes appear to cause a significant performance regression across a number of use-cases.
* [#1915](https://github.com/bbatsov/projectile/pull/1915): Fix
dotnet-sln project-type recognition (check `*.sln` files instead of
`src/`)

### New features

Expand Down
8 changes: 7 additions & 1 deletion projectile.el
Original file line number Diff line number Diff line change
Expand Up @@ -3058,6 +3058,12 @@ it acts on the current project."
(or (projectile-verify-file-wildcard "?*.csproj" dir)
(projectile-verify-file-wildcard "?*.fsproj" dir)))

(defun projectile-dotnet-sln-project-p (&optional dir)
"Check if a project contains a .NET solution project marker.
When DIR is specified it checks DIR's project, otherwise
it acts on the current project."
(or (projectile-verify-file-wildcard "?*.sln" dir)))

(defun projectile-go-project-p (&optional dir)
"Check if a project contains Go source files.
When DIR is specified it checks DIR's project, otherwise
Expand Down Expand Up @@ -3271,7 +3277,7 @@ a manual COMMAND-TYPE command is created with
:compile "dotnet build"
:run "dotnet run"
:test "dotnet test")
(projectile-register-project-type 'dotnet-sln '("src")
(projectile-register-project-type 'dotnet-sln #'projectile-dotnet-sln-project-p
:project-file "?*.sln"
:compile "dotnet build"
:run "dotnet run"
Expand Down
4 changes: 2 additions & 2 deletions test/projectile-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -1347,11 +1347,11 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'.
(let ((projectile-indexing-method 'native))
(spy-on 'projectile-project-root :and-return-value (file-truename (expand-file-name "project/")))
(expect (projectile-detect-project-type) :to-equal 'emacs-eldev)))))
(it "detects project-type for projects with src dir and no other marker"
(it "detects project-type for dotnet sln projects"
(projectile-test-with-sandbox
(projectile-test-with-files
("project/"
"project/src/")
"project/Project.sln")
(let ((projectile-indexing-method 'native))
(spy-on 'projectile-project-root :and-return-value (file-truename (expand-file-name "project/")))
(expect (projectile-detect-project-type) :to-equal 'dotnet-sln)))))
Expand Down

0 comments on commit 8714de5

Please sign in to comment.