dbosoft / YaNco

.NET SAP RFC API based on SAP Netweaver RFC SDK
MIT License
123 stars 15 forks source link

`NullReferenceException` when calling `Dbosoft.YaNco.Table.GetTypeDescription()` method #260

Closed prodehghan closed 1 year ago

prodehghan commented 1 year ago

Call stack:

at Dbosoft.YaNco.Internal.Api.GetTypeDescription(IDataContainerHandle dataContainer, RfcErrorInfo& errorInfo) in /src/YaNco.Core/Internal/Api.cs:line 79 at Dbosoft.YaNco.RfcRuntime.GetTypeDescription(IDataContainerHandle dataContainer) in /src/YaNco.Core/RfcRuntime.cs:line 167 at Dbosoft.YaNco.DataContainer.GetTypeDescription() in /src/YaNco.Core/DataContainer.cs:line 53

What is null?

The dataContainer that is passed to Api.GetTypeDescription is null.

Why?

In RfcRuntime.cs, line 167 we have:

ITypeDescriptionHandle handle = Api.GetTypeDescription(dataContainer as Internal.IDataContainerHandle, out var errorInfo);

Both StructureHandle and FunctionHandle classes implement IDataContainerHandle, but TableHandle class does not. When the GetTypeDescription() method is called on a Table object, since its _handle field does not implement Internal.IDataContainerHandle, the above line of code passes null to the Api.GetTypeDescription.

prodehghan commented 1 year ago

The fix is easy. I'll send a PR.