Description:
In the SystemTextJsonReflectionService class, there are two methods named GetPropertyName with different signatures. The GenerateProperties method calls GetPropertyName, but the compiler resolves this call to the private static method, not the public override method. This makes it impossible to override the GetPropertyName method in a custom ReflectionServiceBase.
Steps to Reproduce:
Create a custom ReflectionServiceBase class.
Override the GetPropertyName method.
Observe that the overridden method is not called in the GenerateProperties method.
Expected Behavior:
The call to GetPropertyName in the GenerateProperties method should resolve to the public override method, allowing it to be overridden in a derived class.
Proposed Solution:
Rename the static method to GetStaticPropertyName or modify its signature to avoid the conflict.
Code Example:
public override string GetPropertyName(ContextualAccessorInfo accessorInfo, JsonSchemaGeneratorSettings settings);
private static string GetPropertyName(ContextualAccessorInfo accessorInfo, SystemTextJsonSchemaGeneratorSettings settings);
public void GenerateProperties(...)
{
var propertyTypeDescription = GetDescription(accessorInfo.AccessorType, settings.DefaultReferenceTypeNullHandling, settings);
var propertyName = GetPropertyName(accessorInfo, settings); // This resolves to the static method
}
Description: In the
SystemTextJsonReflectionService
class, there are two methods namedGetPropertyName
with different signatures. TheGenerateProperties
method callsGetPropertyName
, but the compiler resolves this call to the private static method, not the public override method. This makes it impossible to override theGetPropertyName
method in a customReflectionServiceBase
.Steps to Reproduce:
ReflectionServiceBase
class.GetPropertyName
method.GenerateProperties
method.Expected Behavior: The call to
GetPropertyName
in theGenerateProperties
method should resolve to the public override method, allowing it to be overridden in a derived class.Proposed Solution: Rename the static method to
GetStaticPropertyName
or modify its signature to avoid the conflict.Code Example: