1111using Genbox . FastData . Misc ;
1212using Genbox . FastData . StringHash ;
1313using Microsoft . Extensions . Logging ;
14+ using Microsoft . Extensions . Logging . Abstractions ;
1415
1516namespace Genbox . FastData ;
1617
17- public static class FastDataGenerator
18+ public static partial class FastDataGenerator
1819{
1920 internal const StringComparison DefaultStringComparison = StringComparison . Ordinal ;
2021
@@ -38,7 +39,7 @@ public static class FastDataGenerator
3839
3940 public static bool TryGenerate < T > ( T [ ] data , FastDataConfig fdCfg , ICodeGenerator generator , out string ? source , ILoggerFactory ? factory = null )
4041 {
41- // factory ??= NullLoggerFactory.Instance;
42+ factory ??= NullLoggerFactory . Instance ;
4243
4344 //Validate that we only have unique data
4445 HashSet < T > uniq = new HashSet < T > ( ) ;
@@ -49,8 +50,20 @@ public static bool TryGenerate<T>(T[] data, FastDataConfig fdCfg, ICodeGenerator
4950 throw new InvalidOperationException ( $ "Duplicate data found: { val } ") ;
5051 }
5152
53+ ILogger logger = factory . CreateLogger ( typeof ( FastDataGenerator ) ) ;
54+ LogUniqueItems ( logger , uniq . Count ) ;
55+
5256 DataProperties < T > props = DataProperties < T > . Create ( data ) ;
5357
58+ LogDataType ( logger , props . DataType ) ;
59+
60+ if ( props . FloatProps != null )
61+ LogMinMaxValues ( logger , props . FloatProps . MinValue , props . FloatProps . MaxValue ) ;
62+ else if ( props . IntProps != null )
63+ LogMinMaxValues ( logger , props . IntProps . MinValue , props . IntProps . MaxValue ) ;
64+ else if ( props . StringProps != null )
65+ LogMinMaxLength ( logger , props . StringProps . LengthData . Min , props . StringProps . LengthData . Max ) ;
66+
5467 IStringHash ? stringHash = null ;
5568 if ( data is string [ ] )
5669 stringHash = /*analysisEnabled ? GetBestHash(stringArr, props.StringProps!, fdCfg.SimulatorConfig, factory) :*/ new DefaultStringHash ( ) ;
@@ -65,16 +78,31 @@ public static bool TryGenerate<T>(T[] data, FastDataConfig fdCfg, ICodeGenerator
6578
6679 IContext ? context = null ;
6780
81+ LogUserStructureType ( logger , fdCfg . StructureType ) ;
6882 foreach ( object candidate in GetDataStructureCandidates ( data , fdCfg , props ) )
6983 {
84+ LogCandidateAttempt ( logger , candidate . GetType ( ) . Name ) ;
85+
7086 if ( candidate is IHashStructure < T > hs )
7187 {
7288 if ( hs . TryCreate ( data , hashFunc , out context ) )
89+ {
90+ LogCandidateSuccess ( logger , candidate . GetType ( ) . Name ) ;
7391 break ;
92+ }
93+
94+ LogCandidateFailed ( logger , candidate . GetType ( ) . Name ) ;
7495 }
7596 else if ( candidate is IStructure < T > s )
97+ {
7698 if ( s . TryCreate ( data , out context ) )
99+ {
100+ LogCandidateSuccess ( logger , candidate . GetType ( ) . Name ) ;
77101 break ;
102+ }
103+
104+ LogCandidateFailed ( logger , candidate . GetType ( ) . Name ) ;
105+ }
78106 }
79107
80108 if ( context == null )
0 commit comments