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

Collection fixes #7

Merged
merged 6 commits into from
Feb 12, 2023
Merged

Collection fixes #7

merged 6 commits into from
Feb 12, 2023

Conversation

Pentiva
Copy link
Contributor

@Pentiva Pentiva commented Feb 9, 2023

This stops the source generator from crashing with a NullReferenceException for ICollection types.
GetEnumeratorSymbol now falls back to implemented interfaces when the provided type symbol does not define one. This method was returning null when given an IReadOnlyCollection and causing the whole generation to fail.
TryGetGenericCollectionInterface was also expanded to support all related collection interfaces.

Tests for both ICollection and IReadOnlyCollection were also added, but are probably overkill, as it was just the generation that was failing and might not be a necessity for ~300 extra tests.

@cathei cathei changed the base branch from main to next February 12, 2023 02:46
@cathei cathei self-assigned this Feb 12, 2023
@cathei cathei merged commit 180b704 into cathei:next Feb 12, 2023
@cathei
Copy link
Owner

cathei commented Feb 12, 2023

Thank you for the contribution! I'll include it in next release.

cathei added a commit that referenced this pull request Feb 12, 2023
cathei added a commit that referenced this pull request Feb 12, 2023
@cathei
Copy link
Owner

cathei commented Feb 12, 2023

I have had some changes with your implementation. I'll leave the note here.

  • There was issue that ICollection is not in System.Collections.Generic but System.Collections. Fixed this.
  • As GetEnumeratorSymbol update does not cover explicit interface implementation, updated this accordingly. It will require additional effort for code generation to fall back explicit interface implementation. It is todo for now.
  • I separated test case to dedicated ones to test generation.

@Pentiva Pentiva deleted the collection_fixes branch February 13, 2023 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants