Support reference type custom converters in source gen#57592
Support reference type custom converters in source gen#57592steveharter merged 1 commit intodotnet:mainfrom
Conversation
|
Tagging subscribers to this area: @eiriktsarpalis, @layomia Issue DetailsFixes #56864
|
| metadataInitSource = $@"{JsonConverterTypeRef} converter = {typeMetadata.ConverterInstantiationLogic}; | ||
| {TypeTypeRef} typeToConvert = typeof({typeCompilableName}); | ||
| if (!converter.CanConvert(typeToConvert)) | ||
| {{ |
There was a problem hiding this comment.
Nit: given that there is a some amount of duplication between the ref type and value type generated code, is there any way we could splice in the nullable check, i.e some thing like
if (!converter.CanConvert(typeToConvert))
{{
{!typeof(T).IsValueType ? "" : EmitNullableTypeHandling()}?
There was a problem hiding this comment.
That is a fair suggestion, and I'll leave it up to @layomia to change it if desired. However, in this case I think it is more readable\understandable to have separate ifs since the amount of emit duplication is only 5 LOC or so.
|
/backport to release/6.0 |
|
Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1148393523 |
|
/backport to release/6.0-rc1 |
|
Started backporting to release/6.0-rc1: https://github.com/dotnet/runtime/actions/runs/1159663823 |
Fixes #56864
Expect this to be ported to https://github.com/dotnet/runtime/tree/release/6.0