@@ -15,11 +15,12 @@ public static class ProjectPersister
1515 #region Public methods
1616
1717 /// <summary>
18- /// Loads the project session data from a specified file.
18+ /// Loads the project session data from a specified file, including validation of referenced files .
1919 /// </summary>
20- /// <param name="projectFileName"></param>
21- /// <returns></returns>
22- public static ProjectData LoadProjectData ( string projectFileName , IPluginRegistry pluginRegistry )
20+ /// <param name="projectFileName">The path to the project file (.lxj)</param>
21+ /// <param name="pluginRegistry">The plugin registry for file system validation</param>
22+ /// <returns>A <see cref="ProjectLoadResult"/> containing the project data and validation results</returns>
23+ public static ProjectLoadResult LoadProjectData ( string projectFileName , IPluginRegistry pluginRegistry )
2324 {
2425 try
2526 {
@@ -31,18 +32,37 @@ public static ProjectData LoadProjectData (string projectFileName, IPluginRegist
3132 var json = File . ReadAllText ( projectFileName , Encoding . UTF8 ) ;
3233 var projectData = JsonConvert . DeserializeObject < ProjectData > ( json , settings ) ;
3334
34- var hasLayout = projectData . TabLayoutXml != null ;
35+ // Set project file path for alternative file search
36+ projectData . ProjectFilePath = projectFileName ;
37+
38+ // Validate all files referenced in the project
3539 var validationResult = ProjectFileValidator . ValidateProject ( projectData , pluginRegistry ) ;
3640
37- return projectData ;
41+ return new ProjectLoadResult
42+ {
43+ ProjectData = projectData ,
44+ ValidationResult = validationResult
45+ } ;
3846 }
3947 catch ( Exception ex ) when ( ex is UnauthorizedAccessException or
4048 IOException or
4149 JsonSerializationException )
4250 {
43-
4451 _logger . Warn ( $ "Error loading persistence data from { projectFileName } , trying old xml version") ;
45- return ProjectPersisterXML . LoadProjectData ( projectFileName ) ;
52+
53+ var projectData = ProjectPersisterXML . LoadProjectData ( projectFileName ) ;
54+
55+ // Set project file path for alternative file search
56+ projectData . ProjectFilePath = projectFileName ;
57+
58+ // Validate files from XML fallback as well
59+ var validationResult = ProjectFileValidator . ValidateProject ( projectData , pluginRegistry ) ;
60+
61+ return new ProjectLoadResult
62+ {
63+ ProjectData = projectData ,
64+ ValidationResult = validationResult
65+ } ;
4666 }
4767 }
4868
0 commit comments