1616using Dynamo . ViewModels ;
1717using Dynamo . Wpf . Properties ;
1818using Newtonsoft . Json ;
19- using Newtonsoft . Json . Linq ;
2019using NotificationObject = Dynamo . Core . NotificationObject ;
2120
2221namespace Dynamo . UI . Controls
@@ -227,18 +226,15 @@ internal void WalkDirectoryTree(System.IO.DirectoryInfo root, SampleFileEntry ro
227226 {
228227 foreach ( System . IO . DirectoryInfo directory in directories )
229228 {
230- // Make sure that the folder name is not "backup" and that it doesn't end with ".dependencies".
231- if ( ! directory . Name . Equals ( Configurations . BackupFolderName ) && ! directory . Name . EndsWith ( ".dependencies" , StringComparison . OrdinalIgnoreCase ) )
229+ //Make sure the folder's name is not "backup" and not "GD"
230+ if ( ! directory . Name . Equals ( Configurations . BackupFolderName ) &&
231+ ! directory . Name . Equals ( "GD" , StringComparison . OrdinalIgnoreCase ) )
232232 {
233233 // Recursive call for each subdirectory.
234234 SampleFileEntry sampleFileEntry =
235235 new SampleFileEntry ( directory . Name , directory . FullName ) ;
236236 WalkDirectoryTree ( directory , sampleFileEntry ) ;
237- // Only add the directory entry if it contains .dyn files (either directly or in subdirectories)
238- if ( sampleFileEntry . Children ? . Any ( ) == true )
239- {
240- rootProperty . AddChildSampleFile ( sampleFileEntry ) ;
241- }
237+ rootProperty . AddChildSampleFile ( sampleFileEntry ) ;
242238 }
243239 }
244240 }
@@ -251,12 +247,6 @@ internal void WalkDirectoryTree(System.IO.DirectoryInfo root, SampleFileEntry ro
251247 {
252248 foreach ( System . IO . FileInfo file in dynamoFiles )
253249 {
254- // Skip files that have Generative Design as the active linter
255- if ( IsGenerativeDesignFile ( file . FullName ) )
256- {
257- continue ;
258- }
259-
260250 if ( sampleFolderPath == null )
261251 {
262252 sampleFolderPath = Path . GetDirectoryName ( file . FullName ) ;
@@ -600,84 +590,6 @@ private void HandleExternalUrl(StartPageListItem item)
600590 System . Diagnostics . Process . Start ( new ProcessStartInfo ( item . ContextData ) { UseShellExecute = true } ) ;
601591 }
602592
603- /// <summary>
604- /// Checks if a .dyn file has Generative Design as the active linter
605- /// </summary>
606- /// <param name="filePath">The file path to the dynamo file</param>
607- /// <returns>True if the file has Generative Design as the active linter, false otherwise</returns>
608- private bool IsGenerativeDesignFile ( string filePath )
609- {
610- if ( ! filePath . ToLower ( ) . EndsWith ( ".dyn" ) && ! filePath . ToLower ( ) . EndsWith ( ".dyf" ) )
611- return false ;
612-
613- try
614- {
615- var jsonObject = DeserializeJsonFile ( filePath ) ;
616- if ( jsonObject == null )
617- return false ;
618-
619- // Check if the file has a "Linting" property (case-insensitive)
620- object lintingObj = null ;
621- foreach ( var key in jsonObject . Keys )
622- {
623- if ( string . Equals ( key , "Linting" , StringComparison . OrdinalIgnoreCase ) )
624- {
625- lintingObj = jsonObject [ key ] ;
626- break ;
627- }
628- }
629-
630- if ( lintingObj == null )
631- return false ;
632-
633- // Handle both JObject (from Newtonsoft.Json) and Dictionary<string, object>
634- string activeLinter = null ;
635- if ( lintingObj is JObject lintingJObject )
636- {
637- // JObject case - access properties directly
638- var activeLinterToken = lintingJObject [ "activeLinter" ] ;
639- if ( activeLinterToken != null )
640- {
641- activeLinter = activeLinterToken . ToString ( ) ;
642- }
643- }
644- else if ( lintingObj is Dictionary < string , object > lintingDict )
645- {
646- // Dictionary case
647- if ( lintingDict . TryGetValue ( "activeLinter" , out object activeLinterObj ) )
648- {
649- activeLinter = activeLinterObj ? . ToString ( ) ;
650- }
651- }
652- else
653- {
654- // Try to convert to string and parse as JObject
655- try
656- {
657- var lintingJObj = JObject . Parse ( lintingObj . ToString ( ) ) ;
658- var activeLinterToken = lintingJObj [ "activeLinter" ] ;
659- if ( activeLinterToken != null )
660- {
661- activeLinter = activeLinterToken . ToString ( ) ;
662- }
663- }
664- catch
665- {
666- return false ;
667- }
668- }
669-
670- // Check if the active linter is "Generative Design"
671- return string . Equals ( activeLinter , "Generative Design" , StringComparison . OrdinalIgnoreCase ) ;
672- }
673- catch ( Exception ex )
674- {
675- // If we can't parse the file, assume it's not a Generative Design file
676- DynamoViewModel . Model . Logger . Log ( "Error checking linter in dynamo graph file: " + ex . Message ) ;
677- return false ;
678- }
679- }
680-
681593 /// <summary>
682594 /// Attempts to deserialize a dynamo graph file and extract metadata from it
683595 /// </summary>
0 commit comments