Details
-
Bug
-
Resolution: Gone away
-
Unknown
-
None
-
2.19.0
-
None
Description
Prerequisite
I have the following document:
1
|
{
|
2
|
"State": {
|
3
|
"Date": null,
|
4
|
"Time": null,
|
5
|
"Filters": {
|
6
|
"_t": "System.Collections.Generic.List`1[[JobManager.Common.TimeFilter, JobManager.Common]]",
|
7
|
"_v": [
|
8
|
{
|
9
|
"Type": 2,
|
10
|
"Values": [
|
11
|
6
|
12
|
],
|
13
|
"Mode": 1
|
14
|
}
|
15
|
]
|
16
|
}
|
17
|
}
|
18
|
}
|
*irrelevant parts omitted
Mapped to the following c# Type
1
|
public class ObjectDescriptor
|
2
|
{
|
3
|
public string? Id { get; set; }
|
4
|
public string? TypeName { get; set; }
|
5
|
public ObjectState? State { get; set; }
|
6
|
}
|
where ObjectState
1
|
public class ObjectState : Dictionary<string, object?>
|
The actual instance of the dictionary contains a key called Filters ,
with a value of type List<TimeFilter>
The class TimeFilter
1
|
public class TimeFilter
|
2
|
{
|
3
|
public TimeFilterType Type { get; set; } //Enum
|
4
|
public IList<int>? Values { get; set; }
|
5
|
public TimeFilterMode Mode { get; set; } //Enum
|
6
|
}
|
Problem
The method GetActualType in class TypeNameDiscriminator calls {{TryParseGenericTypeName }}passing the following typeName:
1
|
System.Collections.Generic.List`1[[JobManager.Common.TimeFilter, JobManager.Common]]
|
At first call, returns as typeArgumentNames the following string:
[JobManager.Common.TimeFilter, JobManager.Common]
The subsequential recursive call to GetActualType with that argument as typeName,
results in a wrong match in TryParseGenericTypeName (wrongly parsed as generic),
returning an empty string ("") in typeArgumentNames
The empty string causes an exception when is called:
1
|
Type.GetType(typeName);
|
The exception is:
1
|
String cannot have zero length
|
Framework: .NET 7.0.200-preview.22628.1
MongoDB.Driver: 2.19.0