@@ -12,25 +12,33 @@ public class VsPersistenceSolutionService
1212 private ISolutionSerializer ? _solutionSerializer ;
1313 private string ? _solutionFilePath ;
1414
15- public async Task < SharpIdeSolutionModel > LoadSolution ( string solutionFilePath , CancellationToken cancellationToken = default )
15+ public async Task LoadSolution ( string solutionFilePath , SolutionModel vsSln , ISolutionSerializer slnSerializer , CancellationToken cancellationToken = default )
1616 {
17- using var _ = SharpIdeOtel . Source . StartActivity ( ) ;
17+ _vsSolution = vsSln ;
18+ _solutionSerializer = slnSerializer ;
1819 _solutionFilePath = solutionFilePath ;
20+ }
21+ // Weird separation between ReadSolution and LoadSolution is so we can call the static ReadSolution in IdeRoot before all the UI Nodes are ready and DI services injected
22+ public static async Task < ( SharpIdeSolutionModel , SolutionModel , ISolutionSerializer ) > ReadSolution ( string solutionFilePath , CancellationToken cancellationToken = default )
23+ {
24+ using var _ = SharpIdeOtel . Source . StartActivity ( ) ;
1925
26+ ISolutionSerializer ? solutionSerializer ;
27+ SolutionModel vsSolution ;
2028 using ( SharpIdeOtel . Source . StartActivity ( "VsPersistence.OpenSolution" ) )
2129 {
22- _solutionSerializer = SolutionSerializers . GetSerializerByMoniker ( solutionFilePath ) ;
23- Guard . Against . Null ( _solutionSerializer ) ;
24- _vsSolution = await _solutionSerializer . OpenAsync ( solutionFilePath , cancellationToken ) ;
30+ solutionSerializer = SolutionSerializers . GetSerializerByMoniker ( solutionFilePath ) ;
31+ Guard . Against . Null ( solutionSerializer ) ;
32+ vsSolution = await solutionSerializer . OpenAsync ( solutionFilePath , cancellationToken ) ;
2533 }
2634
2735 // This intermediate model is pretty much useless, but I have left it around as we grab the project nodes with it, which we might use later.
28- var intermediateModel = await IntermediateMapper . GetIntermediateModel ( solutionFilePath , _vsSolution , cancellationToken ) ;
36+ var intermediateModel = await IntermediateMapper . GetIntermediateModel ( solutionFilePath , vsSolution , cancellationToken ) ;
2937
3038 var solutionModel = new SharpIdeSolutionModel ( solutionFilePath , intermediateModel ) ;
3139
3240 var gitFolderPath = Repository . Discover ( solutionFilePath ) ;
33- if ( gitFolderPath is null ) return solutionModel ;
41+ if ( gitFolderPath is null ) return ( solutionModel , vsSolution , solutionSerializer ) ;
3442 using var repo = new Repository ( gitFolderPath ) ;
3543 var status = repo . RetrieveStatus ( new StatusOptions ( ) ) ;
3644
@@ -52,7 +60,7 @@ public async Task<SharpIdeSolutionModel> LoadSolution(string solutionFilePath, C
5260 fileInSolution . GitStatus = mappedGitStatus ;
5361 }
5462
55- return solutionModel ;
63+ return ( solutionModel , vsSolution , solutionSerializer ) ;
5664 }
5765
5866 public async Task AddProject ( IExpandableSharpIdeNode parentNode , string projectName , string projectFilePath , CancellationToken cancellationToken = default )
0 commit comments