reqnroll / Reqnroll.VisualStudio

Visual Studio extension for Reqnroll - open-source .NET BDD framework
https://reqnroll.net
BSD 3-Clause "New" or "Revised" License
14 stars 5 forks source link

Reqnroll.json discovery differences between extension and reqnroll package #17

Closed jdb0123 closed 1 month ago

jdb0123 commented 4 months ago

Used Visual Studio

Visual Studio 2022

Are the latest Visual Studio updates installed?

Yes

Content of reqnroll.json (if present)

No response

Issue Description

The ReqnRoll package allows to place the reqnroll.json in other locations than the project folder. However not all supported locations for the reqnroll.json in the package are valid for the visual studio extension.

The extension only seems to check the project folder.

private string GetReqnrollConfigFilePath(IProjectScope projectScope)
{
    var projectFolder = projectScope.ProjectFolder;
    var fileSystem = projectScope.IdeScope.FileSystem;
    return fileSystem.GetFilePathIfExists(Path.Combine(projectFolder,
               ProjectScopeDeveroomConfigurationProvider.ReqnrollJsonConfigFileName)) ??
           fileSystem.GetFilePathIfExists(Path.Combine(projectFolder,
               ProjectScopeDeveroomConfigurationProvider.SpecFlowJsonConfigFileName)) ??
           fileSystem.GetFilePathIfExists(Path.Combine(projectFolder,
               ProjectScopeDeveroomConfigurationProvider.SpecFlowAppConfigFileName));
}

Steps to Reproduce

Link to a project repository that reproduces the issue

No response

gasparnagy commented 4 months ago

@jdb0123 I don't think this is a supported scenario currently. The fact that it works with the Reqnroll runtime is just a lucky coincidence.

What would be your proposed solution for finding the config file in the plugin?

jdb0123 commented 4 months ago

@gasparnagy I think it should be possible to look in the project folder, if not present see if reqnroll.json (or consorts) are present in the project file. Then follow that path and use that file.

gasparnagy commented 4 months ago

@jdb0123 That would make sense, but unfortunately there are so many ways to "include" a file to a project (different patterns, different file includes, Directory.Build.props, etc.). Actually even Reqnroll loads the JSON file in a quite strange way (see ReqnrollJsonLocator). Maybe instead of trying to detect the file include in the project file, we should check if the file exists at the same locations where Reqnroll checks it. (That would require a compilation to copy the file, but after that it would work.) So basically the checking mechanizm that you included would need to be extended by checking the output directory (e.g. bin/Debug/net8.0) as well.

Do you want to try and send a PR for that?

jdb0123 commented 4 months ago

That sounds like a plan. Will give that a shot soon.

jdb0123 commented 2 months ago

@gasparnagy Took a bit longer than expected to start on it. Changes can be found in #31

gasparnagy commented 1 month ago

@jdb0123 Super, thx! I did a review on the PR.

gasparnagy commented 1 month ago

Fixed by #31 , I will release it tomorrow.

jdb0123 commented 2 weeks ago

@gasparnagy would it be possible to release this change, or it is still waiting on some other change?

gasparnagy commented 2 weeks ago

@jdb0123 sorry for the delay. I try to do it today.

gasparnagy commented 2 weeks ago

It is out now: v2024.3.152