@@ -652,6 +652,17 @@ public static object SafeExtractDictionaryValue(Dictionary<string, object> dict,
652652 return null ;
653653 }
654654
655+ private const string DefineDataValidationKey = "Validation" ;
656+
657+ private static Dictionary < string , object > UnusedDefineDataResult ( object inputValue )
658+ {
659+ return new Dictionary < string , object >
660+ {
661+ { ">" , inputValue } ,
662+ { DefineDataValidationKey , null }
663+ } ;
664+ }
665+
655666 /// <summary>
656667 /// This is the function used by AST to evaluate the Define Data node.
657668 /// Handles some of the the node logic while performing the validation
@@ -669,23 +680,15 @@ public static Dictionary<string, object> EvaluateDefineDataNode([ArbitraryDimens
669680 if ( inputValue == null && string . IsNullOrEmpty ( playerValue ) )
670681 {
671682 // Don't raise a warning if the node is unused
672- return new Dictionary < string , object >
673- {
674- { ">" , inputValue } ,
675- { "Validation" , null }
676- } ;
683+ return UnusedDefineDataResult ( inputValue ) ;
677684 }
678685
679686 // Unconnected var[]..[] ports can receive an empty sequence default.
680687 if ( string . IsNullOrEmpty ( playerValue )
681688 && inputValue is IEnumerable enumerable and not string
682689 && ! enumerable . Cast < object > ( ) . Any ( ) )
683690 {
684- return new Dictionary < string , object >
685- {
686- { ">" , inputValue } ,
687- { "Validation" , null }
688- } ;
691+ return UnusedDefineDataResult ( inputValue ) ;
689692 }
690693
691694 // If the playerValue is not empty, then we assume it was set by the player.
@@ -709,11 +712,7 @@ public static Dictionary<string, object> EvaluateDefineDataNode([ArbitraryDimens
709712 // follow the same behavior as an unused Define Data input.
710713 if ( inputValue == null )
711714 {
712- return new Dictionary < string , object >
713- {
714- { ">" , inputValue } ,
715- { "Validation" , null }
716- } ;
715+ return UnusedDefineDataResult ( inputValue ) ;
717716 }
718717
719718 if ( ! IsSingleValueOrSingleLevelArrayList ( inputValue ) )
@@ -736,16 +735,7 @@ public static Dictionary<string, object> EvaluateDefineDataNode([ArbitraryDimens
736735 // Type logic - we try to 'guess' the type of the object
737736 if ( type == null || ! IsSupportedDataNodeDynamoType ( inputValue , type . Type , assertList ) )
738737 {
739- var valueType = assertList ? FindCommonAncestor ( arrayList ) : inputValue ? . GetType ( ) ;
740- if ( ! assertList && valueType == null )
741- {
742- // Defensive null-safe fallback for analyzers: no input means no validation result.
743- return new Dictionary < string , object >
744- {
745- { ">" , inputValue } ,
746- { "Validation" , null }
747- } ;
748- }
738+ var valueType = assertList ? FindCommonAncestor ( arrayList ) : inputValue . GetType ( ) ;
749739 if ( valueType == null )
750740 {
751741 // We couldn't find a common ancestor - list containing unsupported or incompatible data types
@@ -820,7 +810,7 @@ private static Dictionary<string, object> DefineDataResult(object inputValue, bo
820810 return new Dictionary < string , object >
821811 {
822812 { ">" , inputValue } ,
823- { "Validation" , result }
813+ { DefineDataValidationKey , result }
824814 } ;
825815 }
826816
0 commit comments