You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/c#/GeneralUpdate.Core/FileSystem/StorageManager.cs
+24-12Lines changed: 24 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
usingSystem;
1
+
usingSystem;
2
2
usingSystem.Collections.Generic;
3
3
usingSystem.IO;
4
4
usingSystem.Linq;
@@ -72,7 +72,7 @@ public sealed class StorageManager
72
72
/// Example of setting: <c>StorageManager.BlackMatcher = new BlackMatcher(config);</c>
73
73
/// </remarks>
74
74
publicstaticIBlackMatcher?BlackMatcher{get;set;}
75
-
75
+
76
76
privateComparisonResultComparisonResult{get;set;}
77
77
78
78
#region Public Methods
@@ -140,15 +140,18 @@ public ComparisonResult Compare(string leftDir, string rightDir)
140
140
141
141
/// <summary>
142
142
/// Serializes an object to JSON and writes it to the specified path.
143
+
/// Uses source generator via <c>JsonTypeInfo</c> to avoid runtime reflection in AOT compilation scenarios.
143
144
/// </summary>
144
145
/// <typeparam name="T">The type of the object to serialize. Must be a reference type.</typeparam>
145
146
/// <param name="targetPath">The full path of the target JSON file.</param>
146
147
/// <param name="obj">The object instance to serialize.</param>
147
-
/// <param name="typeInfo">Optional JSON type info metadata for source generator serialization support.</param>
148
+
/// <param name="typeInfo">JSON type info metadata for source generator serialization support. When <c>null</c>, the reflection-based serializer is used (not AOT-compatible); pass a generated context for Native AOT support.</param>
148
149
/// <exception cref="ArgumentException">Thrown when <paramref name="targetPath"/> does not contain a valid directory path.</exception>
149
150
/// <remarks>
150
151
/// If the directory of the target file does not exist, it will be created automatically.
151
-
/// Supports source generator mode via <c>JsonTypeInfo</c>, which avoids runtime reflection in AOT compilation scenarios.
152
+
/// When <paramref name="typeInfo"/> is null, this method falls back to the reflection-based serializer
153
+
/// which is not compatible with Native AOT. For AOT compilation, always pass a generated
/// Reads a JSON file from the specified path and deserializes it into the specified type.
175
+
/// Uses source generator via <c>JsonTypeInfo</c> to avoid runtime reflection in AOT compilation scenarios.
167
176
/// </summary>
168
177
/// <typeparam name="T">The target type for deserialization. Must be a reference type.</typeparam>
169
178
/// <param name="path">The full path of the JSON file.</param>
170
-
/// <param name="typeInfo">Optional JSON type info metadata for source generator deserialization support.</param>
179
+
/// <param name="typeInfo">JSON type info metadata for source generator deserialization support. When <c>null</c>, the reflection-based serializer is used (not AOT-compatible); pass a generated context for Native AOT support.</param>
171
180
/// <returns>The deserialized object instance; returns <c>default</c> if the file does not exist.</returns>
172
181
/// <remarks>
173
182
/// If the file does not exist, no exception is thrown and <c>null</c> is returned.
174
-
/// Supports source generator mode via <c>JsonTypeInfo</c>.
183
+
/// When <paramref name="typeInfo"/> is null, this method falls back to the reflection-based serializer
184
+
/// which is not compatible with Native AOT. For AOT compilation, always pass a generated
0 commit comments