CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
object_with_parameterized_constructor_converter.h
1#pragma once
2
3#include <system/value_tuple.h>
4#include <system/type_info.h>
5#include <system/span.h>
6#include <system/primitive_types.h>
7#include <system/object_ext.h>
8#include <system/nullable.h>
9#include <system/math.h>
10#include <system/diagnostics/debug.h>
11#include <system/details/pointer_collection_helpers.h>
12#include <system/details/patterns.h>
13#include <system/default.h>
14#include <system/constraints.h>
15#include <system/collections/idictionary.h>
16#include <system/collections/collection_extensions.h>
17#include <system/array.h>
18#include <system/action.h>
19#include <cstdint>
20
21#include "system/text/json/json_collection_extensions.h"
22#include "system/text/json/serialization/converters/object/object_default_converter.h"
23#include "system/text/json/reader/utf8_json_reader.h"
24#include "system/text/json/serialization/json_serializer_options.h"
25#include "system/text/json/serialization/read_stack.h"
26#include "system/text/json/serialization/read_stack_frame.h"
27#include "system/text/json/serialization/argument_state.h"
28#include "system/text/json/json_token_type.h"
29#include "system/text/json/throw_helper.h"
30#include "system/text/json/reader/json_reader_state.h"
31#include "system/text/json/serialization/json_serializer_helpers.h"
32#include "system/text/json/serialization/stack_frame_object_state.h"
33#include "system/text/json/serialization/metadata_property_name.h"
34#include "system/text/json/serialization/polymorphic_serialization_state.h"
35#include "system/text/json/serialization/json_converter.h"
36#include "system/text/json/document/json_element.h"
37#include "system/text/json/serialization/metadata/json_type_info_kind.h"
38#include "system/text/json/json_helpers.h"
39#include "system/text/json/serialization/stack_frame_property_state.h"
40
41namespace System
42{
43namespace Text
44{
45namespace Json
46{
47class JsonElement;
48} // namespace Json
49} // namespace Text
50} // namespace System
51
52namespace System {
53
54namespace Text {
55
56namespace Json {
57
58namespace Serialization {
59
60namespace Converters {
61
62template<typename T>
64{
67
68 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
69 RTTI_INFO_TEMPLATE_CLASS(ThisType, ThisTypeBaseTypesInfo);
70
71 template<typename FT0> friend class ObjectWithParameterizedConstructorConverter;
72
73public:
74
76 {
77 return true;
78 }
79
80 bool OnTryRead(Utf8JsonReader& reader, const System::TypeInfo& typeToConvert, System::SharedPtr<JsonSerializerOptions> options, ReadStack& state, T& value) override
81 {
83
84 if (!jsonTypeInfo->get_UsesParameterizedConstructor() || state.Current.IsPopulating)
85 {
86 // Fall back to default object converter in following cases:
87 // - if user configuration has invalidated the parameterized constructor
88 // - we're continuing populating an object.
90 }
91
94
96 {
97 // Fast path that avoids maintaining state variables.
98
100 {
102 }
103
104 if (System::SafeInvoke(state.get_ParentProperty(), [&](auto&& expr){return expr->TryGetPrePopulatedValue(System::Ref(state));}) == true)
105 {
106 System::SharedPtr<Object> populatedObject = state.Current.ReturnValue;
107 ObjectDefaultConverter<T>::PopulatePropertiesFastPath(populatedObject, jsonTypeInfo, options, System::Ref(reader), System::Ref(state));
108 value = System::ExplicitCast<T>(populatedObject);
109 return true;
110 }
111
112 ReadOnlySpan<uint8_t> originalSpan = reader.get_OriginalSpan();
114
115 ReadConstructorArguments(System::Ref(state), System::Ref(reader), options);
116
117 // We've read all ctor parameters and properties,
118 // validate that all required parameters were provided
119 // before calling the constructor which may throw.
121
122 obj = System::ExplicitCast<System::Object>(System::ExplicitCast<T>(CreateObject(System::Ref(state.Current))));
123
124 jsonTypeInfo->InvokeOnDeserializing(obj);
125
126 if (argumentState->FoundPropertyCount > 0)
127 {
128 Utf8JsonReader tempReader;
129
131 for (int32_t i = 0; i < argumentState->FoundPropertyCount; i++)
132 {
133 System::SharedPtr<Metadata::JsonPropertyInfoBase> jsonPropertyInfo = properties[i].template Item<0>();
134 int64_t resumptionByteIndex = properties[i].template Item<2>();
135 System::SharedPtr<Array<uint8_t>> propertyNameArray = properties[i].template Item<3>();
136 String dataExtKey = properties[i].template Item<4>();
137
138 tempReader = originalSequence.get_IsEmpty() ? Utf8JsonReader(originalSpan.Slice(System::CheckedCast<int32_t>(resumptionByteIndex)), true, properties[i].template Item<1>()) : Utf8JsonReader(originalSequence.Slice(resumptionByteIndex), true, properties[i].template Item<1>());
139
140 state.Current.JsonPropertyName = propertyNameArray;
141 state.Current.JsonPropertyInfo = jsonPropertyInfo;
142 state.Current.NumberHandling = jsonPropertyInfo->get_EffectiveNumberHandling();
143
144 bool useExtensionProperty = !(dataExtKey == nullptr);
145
146 if (useExtensionProperty)
147 {
148 state.Current.JsonPropertyNameAsString = dataExtKey;
150 }
151
152 ObjectDefaultConverter<T>::ReadPropertyValue(obj, System::Ref(state), System::Ref(tempReader), jsonPropertyInfo, useExtensionProperty);
153 }
154
156 argumentState->FoundProperties.reset();
158 }
159 }
160 else
161 {
162 // Slower path that supports continuation and metadata reads.
163
165 {
167 {
169 }
170
172 }
173
174 // Read any metadata properties.
176 {
178 {
179 value = System::Default<T>();
180 return false;
181 }
182
184 }
185
186 // Dispatch to any polymorphic converters: should always be entered regardless of ObjectState progress
187 System::SharedPtr<JsonConverterBase> polymorphicConverter;
188 if (((state.Current.MetadataPropertyNames & System::Text::Json::MetadataPropertyName::Type)!= static_cast<MetadataPropertyName>(0) || System::Is(state.PolymorphicResolvedType, !(_== nullptr))) && state.Current.PolymorphicSerializationState != System::Text::Json::PolymorphicSerializationState::PolymorphicReEntryStarted && System::Is<JsonConverterBase>(this->ResolvePolymorphicConverter(jsonTypeInfo, System::Ref(state)), polymorphicConverter))
189 {
190 System::SharedPtr<Object> objectResult;
191 bool success = polymorphicConverter->OnTryReadAsObject(System::Ref(reader), polymorphicConverter->get_Type(), options, System::Ref(state), objectResult);
192 value = System::ExplicitCast<T>(objectResult);
193 state.ExitPolymorphicConverter(success);
194 return success;
195 }
196
197 // We need to populate before we started reading constructor arguments.
198 // Metadata is disallowed with Populate option and therefore ordering here is irrelevant.
199 // Since state.Current.IsPopulating is being checked early on in this method the continuation
200 // will be handled there.
201 if (System::SafeInvoke(state.get_ParentProperty(), [&](auto&& expr){return expr->TryGetPrePopulatedValue(System::Ref(state));}) == true)
202 {
203 System::SharedPtr<Object> populatedObject = state.Current.ReturnValue;
204
205 jsonTypeInfo->InvokeOnDeserializing(populatedObject);
209 }
210
211 // Handle metadata post polymorphic dispatch
213 {
214 if (state.Current.CanContainMetadata)
215 {
217 }
218
219 BeginRead(System::Ref(state), options);
220
222 }
223
224 if (!ReadConstructorArgumentsWithContinuation(System::Ref(state), System::Ref(reader), options))
225 {
226 value = System::Default<T>();
227 return false;
228 }
229
230 // We've read all ctor parameters and properties,
231 // validate that all required parameters were provided
232 // before calling the constructor which may throw.
234
235 obj = System::ExplicitCast<System::Object>(System::ExplicitCast<T>(CreateObject(System::Ref(state.Current))));
236
237 jsonTypeInfo->InvokeOnDeserializing(obj);
238
239 if (argumentState->FoundPropertyCount > 0)
240 {
241 for (int32_t i = 0; i < argumentState->FoundPropertyCount; i++)
242 {
243 System::SharedPtr<Metadata::JsonPropertyInfoBase> jsonPropertyInfo = argumentState->FoundPropertiesAsync[i].template Item<0>();
244 System::SharedPtr<Object> propValue = argumentState->FoundPropertiesAsync[i].template Item<1>();
245 String dataExtKey = argumentState->FoundPropertiesAsync[i].template Item<2>();
246
247 if (dataExtKey == nullptr)
248 {
249 if (!(propValue == nullptr) || !jsonPropertyInfo->get_IgnoreNullTokensOnRead() || !System::IsNull(System::Default<T>()))
250 {
251 jsonPropertyInfo->get_Set()(obj, propValue);
252 }
253 }
254 else
255 {
257 System::SharedPtr<Object> extDictionary = jsonPropertyInfo->GetValueAsObject(obj);
258
260 if (System::Is<Collections::Generic::IDictionary<String, JsonElement>>(extDictionary, dict))
261 {
262 dict->idx_set(dataExtKey, System::ExplicitCast<System::Text::Json::JsonElement>(propValue));
263 }
264 else
265 {
266 System::SharedPtr<Collections::Generic::IDictionary<String, System::SharedPtr<Object>>> objDict = System::ExplicitCast<System::Collections::Generic::IDictionary<System::String, System::SharedPtr<System::Object>>>(extDictionary);
267
268 objDict->idx_set(dataExtKey, propValue);
269 }
270 }
271 }
272
274 argumentState->FoundPropertiesAsync.reset();
276 }
277 }
278
279 jsonTypeInfo->InvokeOnDeserialized(obj);
280
281 // Unbox
282 value = System::ExplicitCast<T>(obj);
283
284 // Check if we are trying to update the UTF-8 property cache.
285 if (System::Is(state.Current.PropertyRefCacheBuilder, !(_== nullptr)))
286 {
287 jsonTypeInfo->UpdateUtf8PropertyCache(System::Ref(state.Current));
288 }
289
290 return true;
291 }
292
293 void SetTemplateWeakPtr(uint32_t argument) override
294 {
295 switch (argument)
296 {
297 case 0:
299 break;
300
301 }
302 }
303
304protected:
305
310 {
311 bool useExtensionProperty;
312 jsonPropertyInfo = System::Text::Json::Serialization::Details::LookupProperty(nullptr, unescapedPropertyName, System::Ref(state), options, useExtensionProperty, false);
313
314 // Mark the property as read from the payload if it is mapped to a non-extension member.
316 {
317 state.Current.MarkPropertyAsRead(jsonPropertyInfo.get());
318 }
319
320 jsonParameterInfo = jsonPropertyInfo->get_AssociatedParameter();
321 if (!(jsonParameterInfo == nullptr))
322 {
323 state.Current.JsonPropertyInfo.reset();
324 state.Current.CtorArgumentState->JsonParameterInfo = jsonParameterInfo;
325 state.Current.NumberHandling = jsonParameterInfo->get_NumberHandling();
326 return true;
327 }
328 else
329 {
330 state.Current.UseExtensionProperty = useExtensionProperty;
331 return false;
332 }
333 }
334
336 {
337 }
338
339private:
340
341 void ReadConstructorArguments(ReadStack& state, Utf8JsonReader& reader, System::SharedPtr<JsonSerializerOptions> options)
342 {
343 BeginRead(System::Ref(state), options);
344
345 while (true)
346 {
347 // Read the next property name or EndObject.
349
350 JsonTokenType tokenType = reader.get_TokenType();
351
353 {
354 return;
355 }
356
357 // Read method would have thrown if otherwise.
358 bool isAlreadyReadMetadataProperty;
359 ReadOnlySpan<uint8_t> unescapedPropertyName = System::Text::Json::Serialization::Details::GetPropertyName(System::Ref(state), System::Ref(reader), options, isAlreadyReadMetadataProperty);
360 if (isAlreadyReadMetadataProperty)
361 {
362 state.Current.EndProperty();
363 continue;
364 }
365
367 if (TryLookupConstructorParameter(unescapedPropertyName, System::Ref(state), options, jsonPropertyInfo, jsonParameterInfo))
368 {
369 // Set the property value.
371
372 if (!jsonParameterInfo->get_ShouldDeserialize())
373 {
374 // The Utf8JsonReader.Skip() method will fail fast if it detects that we're reading
375 // from a partially read buffer, regardless of whether the next value is available.
376 // This can result in erroneous failures in cases where a custom converter is calling
377 // into a built-in converter (cf. https://github.com/dotnet/runtime/issues/74108).
378 // For this reason we need to call the TrySkip() method instead -- the serializer
379 // should guarantee sufficient read-ahead has been performed for the current object.
380 bool success = reader.TrySkip();
381 CODEPORTING_DEBUG_ASSERT2(success, u"Serializer should guarantee sufficient read-ahead has been done.");
382
384 continue;
385 }
386 ReadAndCacheConstructorArgument(System::Ref(state), System::Ref(reader), jsonParameterInfo);
387
389 }
390 else
391 {
392 if (jsonPropertyInfo->get_CanDeserialize())
393 {
395
396 if (argumentState->FoundProperties == nullptr)
397 {
398 argumentState->FoundProperties = Buffers::ArrayPool<ValueTuple<System::SharedPtr<Metadata::JsonPropertyInfoBase>, JsonReaderState, int64_t, System::SharedPtr<Array<uint8_t>>, String>>::get_Shared()->Rent(System::Math::Max(1, state.Current.JsonTypeInfo->get_PropertyCache().get_Length()));
399 }
400 else if (argumentState->FoundPropertyCount == argumentState->FoundProperties->get_Length())
401 {
402 // Rare case where we can't fit all the JSON properties in the rented pool; we have to grow.
403 // This could happen if there are duplicate properties in the JSON.
404
405 auto newCache = Buffers::ArrayPool<ValueTuple<System::SharedPtr<Metadata::JsonPropertyInfoBase>, JsonReaderState, int64_t, System::SharedPtr<Array<uint8_t>>, String>>::get_Shared()->Rent(argumentState->FoundProperties->get_Length() * 2);
406
407 argumentState->FoundProperties->CopyTo(newCache, 0);
408
409 System::SharedPtr<Array<ValueTuple<System::SharedPtr<Metadata::JsonPropertyInfoBase>, JsonReaderState, int64_t, System::SharedPtr<Array<uint8_t>>, String>>> toReturn = argumentState->FoundProperties;
410 argumentState->FoundProperties = newCache;
411
412 Buffers::ArrayPool<ValueTuple<System::SharedPtr<Metadata::JsonPropertyInfoBase>, JsonReaderState, int64_t, System::SharedPtr<Array<uint8_t>>, String>>::get_Shared()->Return(toReturn, true);
413 }
414
415 argumentState->FoundProperties[argumentState->FoundPropertyCount++] = System::MakeTuple(jsonPropertyInfo,
416 reader.get_CurrentState(),
417 reader.get_BytesConsumed(),
420 }
421
423 state.Current.EndProperty();
424 }
425 }
426 }
427
428 bool ReadConstructorArgumentsWithContinuation(ReadStack& state, Utf8JsonReader& reader, System::SharedPtr<JsonSerializerOptions> options)
429 {
430 // Process all properties.
431 while (true)
432 {
433 // Determine the property.
434 if (state.Current.PropertyState == System::Text::Json::StackFramePropertyState::None)
435 {
436 if (!reader.Read())
437 {
438 return false;
439 }
440
441 state.Current.PropertyState = System::Text::Json::StackFramePropertyState::ReadName;
442 }
443
446
447 if (state.Current.PropertyState < System::Text::Json::StackFramePropertyState::Name)
448 {
449 JsonTokenType tokenType = reader.get_TokenType();
450
452 {
453 return true;
454 }
455
456 // Read method would have thrown if otherwise.
457
458 bool isAlreadyReadMetadataProperty;
459 ReadOnlySpan<uint8_t> unescapedPropertyName = System::Text::Json::Serialization::Details::GetPropertyName(System::Ref(state), System::Ref(reader), options, isAlreadyReadMetadataProperty);
460 if (isAlreadyReadMetadataProperty)
461 {
463 state.Current.EndProperty();
464 continue;
465 }
466
467 if (TryLookupConstructorParameter(unescapedPropertyName, System::Ref(state), options, jsonPropertyInfo, jsonParameterInfo))
468 {
469 jsonPropertyInfo.reset();
470 }
471
472 state.Current.PropertyState = System::Text::Json::StackFramePropertyState::Name;
473 }
474 else
475 {
476 jsonParameterInfo = state.Current.CtorArgumentState->JsonParameterInfo;
477 jsonPropertyInfo = state.Current.JsonPropertyInfo;
478 }
479
480 if (!(jsonParameterInfo == nullptr))
481 {
482 if (!HandleConstructorArgumentWithContinuation(System::Ref(state), System::Ref(reader), jsonParameterInfo))
483 {
484 return false;
485 }
486 }
487 else
488 {
489 if (!HandlePropertyWithContinuation(System::Ref(state), System::Ref(reader), jsonPropertyInfo))
490 {
491 return false;
492 }
493 }
494 }
495 }
496
497 bool HandleConstructorArgumentWithContinuation(ReadStack& state, Utf8JsonReader& reader, System::SharedPtr<Metadata::JsonParameterInfoBase> jsonParameterInfo)
498 {
499 if (state.Current.PropertyState < System::Text::Json::StackFramePropertyState::ReadValue)
500 {
501 if (!jsonParameterInfo->get_ShouldDeserialize())
502 {
503 if (!reader.TrySkipPartial(state.Current.OriginalDepth + 1))
504 {
505 return false;
506 }
507
508 state.Current.EndConstructorParameter();
509 return true;
510 }
511
512 if (!JsonHelpers::TryAdvanceWithOptionalReadAhead(reader, jsonParameterInfo->get_EffectiveConverter()->get_RequiresReadAhead()))
513 {
514 return false;
515 }
516
517 state.Current.PropertyState = System::Text::Json::StackFramePropertyState::ReadValue;
518 }
519
520 if (!ReadAndCacheConstructorArgument(System::Ref(state), System::Ref(reader), jsonParameterInfo))
521 {
522 return false;
523 }
524
525 state.Current.EndConstructorParameter();
526 return true;
527 }
528
529 static bool HandlePropertyWithContinuation(ReadStack& state, Utf8JsonReader& reader, System::SharedPtr<Metadata::JsonPropertyInfoBase> jsonPropertyInfo)
530 {
531 if (state.Current.PropertyState < System::Text::Json::StackFramePropertyState::ReadValue)
532 {
533 if (!jsonPropertyInfo->get_CanDeserialize())
534 {
535 if (!reader.TrySkipPartial(state.Current.OriginalDepth + 1))
536 {
537 return false;
538 }
539
540 state.Current.EndProperty();
541 return true;
542 }
543
544 if (!ObjectDefaultConverter<T>::ReadAheadPropertyValue(System::Ref(state), System::Ref(reader), jsonPropertyInfo))
545 {
546 return false;
547 }
548
549 state.Current.PropertyState = System::Text::Json::StackFramePropertyState::ReadValue;
550 }
551
553
554 if (state.Current.UseExtensionProperty)
555 {
556 if (!jsonPropertyInfo->ReadJsonExtensionDataValue(System::Ref(state), System::Ref(reader), propValue))
557 {
558 return false;
559 }
560 }
561 else
562 {
563 if (!jsonPropertyInfo->ReadJsonAsObject(System::Ref(state), System::Ref(reader), propValue))
564 {
565 return false;
566 }
567 }
568
569 // Ensure that the cache has enough capacity to add this property.
570
571 System::SharedPtr<ArgumentState> argumentState = state.Current.CtorArgumentState;
572
573 if (argumentState->FoundPropertiesAsync == nullptr)
574 {
575 argumentState->FoundPropertiesAsync = Buffers::ArrayPool<ValueTuple<System::SharedPtr<Metadata::JsonPropertyInfoBase>, System::SharedPtr<Object>, String>>::get_Shared()->Rent(System::Math::Max(1, state.Current.JsonTypeInfo->get_PropertyCache().get_Length()));
576 }
577 else if (argumentState->FoundPropertyCount == argumentState->FoundPropertiesAsync->get_Length())
578 {
579 // Rare case where we can't fit all the JSON properties in the rented pool; we have to grow.
580 // This could happen if there are duplicate properties in the JSON.
581 auto newCache = Buffers::ArrayPool<ValueTuple<System::SharedPtr<Metadata::JsonPropertyInfoBase>, System::SharedPtr<Object>, String>>::get_Shared()->Rent(argumentState->FoundPropertiesAsync->get_Length() * 2);
582
583 argumentState->FoundPropertiesAsync->CopyTo(newCache, 0);
584
586 argumentState->FoundPropertiesAsync = newCache;
587
588 Buffers::ArrayPool<ValueTuple<System::SharedPtr<Metadata::JsonPropertyInfoBase>, System::SharedPtr<Object>, String>>::get_Shared()->Return(toReturn, true);
589 }
590
591 // Cache the property name and value.
592 argumentState->FoundPropertiesAsync[argumentState->FoundPropertyCount++] = System::MakeTuple(jsonPropertyInfo,
593 propValue,
594 state.Current.JsonPropertyNameAsString);
595
596 state.Current.EndProperty();
597 return true;
598 }
599
600 void BeginRead(ReadStack& state, System::SharedPtr<JsonSerializerOptions> options)
601 {
602 System::SharedPtr<Metadata::JsonTypeInfoBase> jsonTypeInfo = state.Current.JsonTypeInfo;
603
604 jsonTypeInfo->ValidateCanBeUsedForPropertyMetadataSerialization();
605
606 if (jsonTypeInfo->get_ParameterCount() != jsonTypeInfo->get_ParameterCache().get_Length())
607 {
609 }
610
611 state.Current.InitializePropertiesValidationState(jsonTypeInfo);
612
613 // Set current JsonPropertyInfo to null to avoid conflicts on push.
614 state.Current.JsonPropertyInfo.reset();
615
617 }
618
619};
620
621} // namespace Converters
622} // namespace Serialization
623} // namespace Json
624} // namespace Text
625} // namespace System
Provides a thread-safe pool for reusing managed array instances (ArrayPtr<T>).
Definition: array_pool.h:21
bool get_IsEmpty() const
Determines whether the sequence is empty.
Definition: read_only_sequence.h:145
ReadOnlySequence Slice(int64_t start) const
Creates a slice of the sequence starting at the given offset.
Definition: read_only_sequence.h:288
Interface for dictionary-alike containers. Objects of this class should only be allocated using Syste...
Definition: idictionary.h:21
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
Pointee_ * get() const
Gets pointed object.
Definition: smart_ptr.h:508
void reset(Pointee_ *ptr)
Sets pointed object.
Definition: smart_ptr.h:520
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:126
static bool TryAdvanceWithOptionalReadAhead(Utf8JsonReader &reader, bool requiresReadAhead)
static void ReadWithVerify(Utf8JsonReader &reader)
static void SkipWithVerify(Utf8JsonReader &reader)
Definition: json_reader_state.h:31
Definition: read_stack_frame.h:42
System::Text::Json::PolymorphicSerializationState PolymorphicSerializationState
Definition: read_stack_frame.h:65
bool IsPopulating
Definition: read_stack_frame.h:76
String JsonPropertyNameAsString
Definition: read_stack_frame.h:55
void InitializePropertiesValidationState(System::SharedPtr< System::Text::Json::Serialization::Metadata::JsonTypeInfoBase > typeInfo)
bool CanContainMetadata
Definition: read_stack_frame.h:62
System::SharedPtr< Array< uint8_t > > JsonPropertyName
Definition: read_stack_frame.h:54
Nullable< Serialization::JsonNumberHandling > NumberHandling
Definition: read_stack_frame.h:73
void MarkPropertyAsRead(System::Text::Json::Serialization::Metadata::JsonPropertyInfoBase *propertyInfo)
bool UseExtensionProperty
Definition: read_stack_frame.h:53
System::SharedPtr< Object > ReturnValue
Definition: read_stack_frame.h:59
MetadataPropertyName MetadataPropertyNames
Definition: read_stack_frame.h:64
System::SharedPtr< System::Text::Json::Serialization::Metadata::PropertyRefCacheBuilder > PropertyRefCacheBuilder
Definition: read_stack_frame.h:71
System::SharedPtr< ArgumentState > CtorArgumentState
Definition: read_stack_frame.h:72
StackFrameObjectState ObjectState
Definition: read_stack_frame.h:61
void ValidateAllRequiredPropertiesAreRead(System::SharedPtr< System::Text::Json::Serialization::Metadata::JsonTypeInfoBase > typeInfo)
System::SharedPtr< System::Text::Json::Serialization::Metadata::JsonPropertyInfoBase > JsonPropertyInfo
Definition: read_stack_frame.h:51
System::SharedPtr< System::Text::Json::Serialization::Metadata::JsonTypeInfoBase > JsonTypeInfo
Definition: read_stack_frame.h:60
Definition: read_stack.h:35
bool SupportContinuation
Definition: read_stack.h:50
void ExitPolymorphicConverter(bool success)
ReadStackFrame Current
Definition: read_stack.h:44
System::SharedPtr< Serialization::Metadata::JsonPropertyInfoBase > get_ParentProperty()
TypeInfo PolymorphicResolvedType
Definition: read_stack.h:52
void SetTemplateWeakPtr(uint32_t argument) override
Set n'th template argument a weak pointer (rather than shared). Allows switching pointers in containe...
Definition: object_default_converter.h:484
static void PopulatePropertiesFastPath(System::SharedPtr< Object > obj, System::SharedPtr< Metadata::JsonTypeInfoBase > jsonTypeInfo, System::SharedPtr< JsonSerializerOptions > options, Utf8JsonReader &reader, ReadStack &state)
Definition: object_default_converter.h:304
static void ReadPropertyValue(System::SharedPtr< Object > obj, ReadStack &state, Utf8JsonReader &reader, System::SharedPtr< Metadata::JsonPropertyInfoBase > jsonPropertyInfo, bool useExtensionProperty)
Definition: object_default_converter.h:497
static bool ReadAheadPropertyValue(ReadStack &state, Utf8JsonReader &reader, System::SharedPtr< Metadata::JsonPropertyInfoBase > jsonPropertyInfo)
Definition: object_default_converter.h:530
bool OnTryRead(Utf8JsonReader &reader, const System::TypeInfo &typeToConvert, System::SharedPtr< JsonSerializerOptions > options, ReadStack &state, T &value) override
Definition: object_default_converter.h:85
Definition: object_with_parameterized_constructor_converter.h:64
void SetTemplateWeakPtr(uint32_t argument) override
Set n'th template argument a weak pointer (rather than shared). Allows switching pointers in containe...
Definition: object_with_parameterized_constructor_converter.h:293
virtual void InitializeConstructorArgumentCaches(ReadStack &state, System::SharedPtr< JsonSerializerOptions > options)=0
bool OnTryRead(Utf8JsonReader &reader, const System::TypeInfo &typeToConvert, System::SharedPtr< JsonSerializerOptions > options, ReadStack &state, T &value) override
Definition: object_with_parameterized_constructor_converter.h:80
bool get_ConstructorIsParameterized() override
Definition: object_with_parameterized_constructor_converter.h:75
virtual ~ObjectWithParameterizedConstructorConverter()
Definition: object_with_parameterized_constructor_converter.h:335
virtual System::SharedPtr< Object > CreateObject(ReadStackFrame &frame)=0
virtual bool ReadAndCacheConstructorArgument(ReadStack &state, Utf8JsonReader &reader, System::SharedPtr< Metadata::JsonParameterInfoBase > jsonParameterInfo)=0
static bool TryLookupConstructorParameter(ReadOnlySpan< uint8_t > unescapedPropertyName, ReadStack &state, System::SharedPtr< JsonSerializerOptions > options, System::SharedPtr< Metadata::JsonPropertyInfoBase > &jsonPropertyInfo, System::SharedPtr< Metadata::JsonParameterInfoBase > &jsonParameterInfo)
Definition: object_with_parameterized_constructor_converter.h:309
Definition: json_converter_of_t.h:80
System::TypeInfo get_Type() override
Definition: json_converter_of_t.h:115
Definition: json_object_converter.h:19
Definition: json_resumable_converter_of_t.h:42
static System::SharedPtr< JsonPropertyInfoBase > s_missingProperty
Definition: json_property_info.h:140
static void ThrowJsonException_DeserializeUnableToConvertValue(const TypeInfo &propertyType)
static void ThrowInvalidOperationException_ConstructorParameterIncompleteBinding(const TypeInfo &parentType)
Definition: utf8_json_reader.h:78
ReadOnlySpan< uint8_t > get_OriginalSpan()
Buffers::ReadOnlySequence< uint8_t > get_OriginalSequence()
Represents a particular type and provides information about it.
Definition: type_info.h:109
@ Text
Defines color adjustment information for text.
void ValidateMetadataForObjectConverter(ReadStack &state)
ReadOnlySpan< uint8_t > GetPropertyName(ReadStack &state, Utf8JsonReader &reader, System::SharedPtr< JsonSerializerOptions > options, bool &isAlreadyReadMetadataProperty)
void CreateExtensionDataProperty(System::SharedPtr< Object > obj, System::SharedPtr< Metadata::JsonPropertyInfoBase > jsonPropertyInfo, System::SharedPtr< JsonSerializerOptions > options)
System::SharedPtr< Metadata::JsonPropertyInfoBase > LookupProperty(System::SharedPtr< Object > obj, ReadOnlySpan< uint8_t > unescapedPropertyName, ReadStack &state, System::SharedPtr< JsonSerializerOptions > options, bool &useExtensionProperty, bool createExtensionProperty=true)
bool TryReadMetadata(System::SharedPtr< JsonConverterBase > converter, System::SharedPtr< Metadata::JsonTypeInfoBase > jsonTypeInfo, Utf8JsonReader &reader, ReadStack &state)
JsonTokenType
Definition: json_token_type.h:12
MetadataPropertyName
Definition: metadata_property_name.h:13
Definition: db_command.h:9
ValueTuple< Args... > MakeTuple(Args... args)
Creates tuple on stack.
Definition: value_tuple.h:300
SmartPtr< X > MakeSharedPtr(X *p)
Converts raw pointer to smart pointer.
Definition: smart_ptr.h:1640
decltype(Ref(std::declval< T & >())) Ref(const std::reference_wrapper< T > &wrapper)
Wrapper to make sure Ref(std::ref(DynamicWeakPtr)) works.
Definition: dynamic_weak_ptr.h:207
static auto SafeInvoke(T0 &&expr, T1 &&func)
Implementation of '?.' operator translation.
Definition: object_ext.h:1434
static auto Max(T0 val1, T1 val2) -> decltype(val1+val2)
Returns the greatest value out of two numeric ones specified.
Definition: math.h:327