Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make TableHandle implement IDataContainerHandle (fixes #260) #261

Merged
merged 1 commit into from
Nov 13, 2023

Conversation

prodehghan
Copy link
Contributor

This fixes NullReferenceException when calling Dbosoft.YaNco.Table.GetTypeDescription() method.

This fixes `NullReferenceException` when calling `Dbosoft.YaNco.Table.GetTypeDescription()` method.
@CLAassistant
Copy link

CLAassistant commented Oct 27, 2023

CLA assistant check
All committers have signed the CLA.

@prodehghan prodehghan changed the title fix: Make TableHandle implement IDataContainerHandle (#260) Make TableHandle implement IDataContainerHandle (fixes #260) Oct 27, 2023
@fw2568
Copy link
Contributor

fw2568 commented Nov 1, 2023

Hello,

thank you for the issue report and the PR.

However just changing ITableHandle to IDataContainerHandle would introduce another issue. IDataContainerHandle is used in all cases where the handle could contain other data (for example in GetStructure, GetTable, GetString, and so on).

Could you please instead introduce another interface ITypeHandle and add it to GetTypeDescription and to IDataContainerHandle and ITableHandle?

Thanks,
Frank

Copy link
Contributor

@fw2568 fw2568 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of adding IDataContainerHandle a new interface ITypeHandle should be used as TableHandle won't work for other use cases of IDataContainerHandle.

@fw2568 fw2568 added the bug Something isn't working label Nov 1, 2023
@prodehghan
Copy link
Contributor Author

prodehghan commented Nov 8, 2023

Hi,

Thanks for the follow up.

Maybe I'm not getting it, but I see some issues here.

There are two interfaces named IDataContainerHandle:

  1. Dbosoft.YaNco.IDataContainerHandle
    • Is implemented by
      • Dbosoft.YaNco.Internal.FunctionHandle (indirectly through IFunctionHandle)
      • Dbosoft.YaNco.Internal.StructureHandle (indirectly through IStructureHandle)
      • Dbosoft.YaNco.Internal.TableHandle (indirectly through ITableHandle)
    • Used as a parameter for the many methods in IRfcRuntime:
      • GetTypeDescription, GetStructure, GetTable, GetString, SetString, ...
    • Stored in DataContainer class, and passed to respective IRfcRuntime methods
  2. Dbosoft.YaNco.Internal.IDataContainerHandle, which inherits from the other one and:
    • Only implemented by:
      • Dbosoft.YaNco.Internal.FunctionHandle
      • Dbosoft.YaNco.Internal.StructureHandle
    • Used as aparamter for many method in Api, which are equivalent to the ones we have in IRfcRuntime.

In RfcRuntime class, the input parameter of many methods is the interface number 1, which when calling Api method, is being cast (as) to the interface number 2.

First of all, I see having these two separate interfaces problematic, causing unnecessary complications. Second, I see no reason for the second interface to not be implemented by TableHandle, as these two interfaces are exactly being used in similar situations.

@fw2568
Copy link
Contributor

fw2568 commented Nov 13, 2023

Sorry for the delay, but now I have looked into this problem.
I added an experimental PR #264 to solve this problem by adding a new overload, but in the end I have to agree with your analysis. However, the real root problem here is that ITableHandle implements IDataContainer for simplification.

However, this makes no sense in terms of the semantic meaning of the data container, as it should only be used for fields that support reading and setting the underlying field values.
However, your solution is the best option for solving the problem.

Again, thanks for your PR and your support. I will merge the PR.

@fw2568 fw2568 merged commit c1070b3 into dbosoft:main Nov 13, 2023
2 checks passed
@fw2568
Copy link
Contributor

fw2568 commented Nov 13, 2023

fixes #260

fw2568 pushed a commit that referenced this pull request Nov 13, 2023
This fixes `NullReferenceException` when calling `Dbosoft.YaNco.Table.GetTypeDescription()` method.
@prodehghan
Copy link
Contributor Author

Thanks for approving the PR.
I agree with you that solving the underlying issue involves a lot more work, but to just fix the bug, this PR is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NullReferenceException when calling Dbosoft.YaNco.Table.GetTypeDescription() method
3 participants