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
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:
publicoverridestringGetPropertyName(ContextualAccessorInfoaccessorInfo,JsonSchemaGeneratorSettingssettings);privatestaticstringGetPropertyName(ContextualAccessorInfoaccessorInfo,SystemTextJsonSchemaGeneratorSettingssettings);publicvoidGenerateProperties(...){varpropertyTypeDescription= GetDescription(accessorInfo.AccessorType, settings.DefaultReferenceTypeNullHandling, settings);varpropertyName= GetPropertyName(accessorInfo, settings);// This resolves to the static method}
The text was updated successfully, but these errors were encountered:
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:
The text was updated successfully, but these errors were encountered: