Skip to content

Conversation

@edvilme
Copy link
Contributor

@edvilme edvilme commented Jan 7, 2025

Addresses #85

This adds a new Serializer for parsing .slnf files into SolutionModel objects. This includes reading the original solution file and filtering projects from there.

@edvilme edvilme marked this pull request as ready for review January 8, 2025 00:12
@edvilme edvilme changed the title (Draft) Support for parsing slnf files Support for parsing slnf files Jan 8, 2025
<None Include="Serializer/Xml/Slnx.xsd" />
</ItemGroup>

<ItemGroup>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in netcore, stj comes from shared framework

Suggested change
<ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">

also update condition on line 10. this is a preferred way of checking the tfm flavor instead of hardcoding version https://github.com/search?q=repo:dotnet/sdk+TargetFrameworkIdentifier+language:XML&type=code

internal SolutionModel Parse()
{
string originalSolutionPath = this.jsonNode["solution"]?["path"]?.GetValue<string>() ?? string.Empty;
string[] projectPaths = this.jsonNode["solution"]?["projects"]?.AsArray()?.GetValues<string>()?.ToArray<string>() ?? [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
string[] projectPaths = this.jsonNode["solution"]?["projects"]?.AsArray()?.GetValues<string>()?.ToArray<string>() ?? [];
IEnumerable<string> projectPaths = this.jsonNode["solution"]?["projects"]?.AsArray()?.GetValues<string>() ?? [];

nit: unnecessary extra array copy due to ToArray

@zivkan
Copy link
Member

zivkan commented Apr 1, 2025

Is there anything I can to do help move this along?

I'm currently working on adding slnf support to a dotnet CLI command, and am surprised that I have to duplicate effort because MSBuild's ProjectFile API doesn't have public APIs to get solution filter information, and this solution persistence library doesn't yet support it.

@richardstanton
Copy link
Member

There was a discussion about this general approach, and creating a solution filter serializer is probably not the right approach. This is because a solution filter file supplements a solution file and doesn't contain any project or configuration data. Having a subset of information is fine for tools reading the data, but a designer like Visual Studio or C# DevKit would not have enough information to update both the solution file and the solution filter.

An approach that would work better would be to create a helper that combines the information from a solution filter and a SolutionModel to provide a filtered view over the list of projects. This would allow solution filters to be used with different solution serializers and keep enough information to be available for designers. This would probably take the form as a set of helpers instead of a serializer.

However, currently supporting solution filters is out of scope.

@edvilme
Copy link
Contributor Author

edvilme commented May 30, 2025

Update for people reading this in the future: dotnet/sdk#46002

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants