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

[registar] Search the entire interface hierarchy for protocols. Fixes #6493. #6514

Merged
merged 1 commit into from
Jul 8, 2019

Conversation

rolfbjarne
Copy link
Member

When we're searching for metadata for marshalling blocks, we must search the
entire interface hierarchy for protocols that implement optional members.

Fixes #6493.

…amarin#6493.

When we're searching for metadata for marshalling blocks, we must search the
entire interface hierarchy for protocols that implement optional members.

Fixes xamarin#6493.
@rolfbjarne rolfbjarne added the bug If an issue is a bug or a pull request a bug fix label Jul 8, 2019
@monojenkins
Copy link
Collaborator

Build failure
Build succeeded
API Diff (from stable)
🔥 Failed to compare API and create generator diff 🔥
    ** Error: Working directory isn't clean:
    HEAD detached at 3c46e04
    Untracked files:
    (use "git add ..." to include in what will be committed)
    
    tests/bcl-test/BCL tests group 1.csproj
    tests/bcl-test/BCL tests group 2.csproj
    tests/bcl-test/BCL tests group 3.csproj
    tests/bcl-test/BCL tests group 4.csproj
    tests/bcl-test/BCL tests group 6.csproj
    tests/bcl-test/Mac OS X BCL tests group 1-mac-full.csproj
    tests/bcl-test/Mac OS X BCL tests group 1-mac-modern.csproj
    tests/bcl-test/Mac OS X BCL tests group 2-mac-full.csproj
    tests/bcl-test/Mac OS X BCL tests group 2-mac-modern.csproj
    tests/bcl-test/Mac OS X BCL tests group 3-mac-full.csproj
    tests/bcl-test/Mac OS X BCL tests group 3-mac-modern.csproj
    tests/bcl-test/Mac OS X BCL tests group 4-mac-full.csproj
    tests/bcl-test/Mac OS X BCL tests group 4-mac-modern.csproj
    tests/bcl-test/generated/
    tests/bcl-test/mscorlib-mac-full.csproj
    tests/bcl-test/mscorlib-mac-modern.csproj
    tests/bcl-test/mscorlib.csproj
    
    nothing added to commit but untracked files present (use "git add" to track)
    Search for Comparing API & creating generator diff in the log to view the complete log.
Test run succeeded

public IEnumerable<ObjCType> AllProtocols {
get {
if (Protocols == null || Protocols.Length == 0)
return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

How important is the null return vs returning an emptyIEnumerable?
It strikes me that you could also do:

bool protocolsRetrieved = false;
HashSet<ObjCType> all_protocols = new HashSet<ObjCType>();
public IEnumerable<ObjCType> AllProtocols {
    if (protocolsRetrieved)
        return all_protocols;
    if (Protocols != null && Protocols.Length > 0) {
        // code to fetch all the protocols here
    }
    protocolsRetrieved = true;
    return all_protocols;
}

Then you don't need the null tests on this type ever.

Copy link
Member Author

Choose a reason for hiding this comment

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

@stephen-hawley because an empty IEnumerable uses more memory than null, and this is something that 99.9% of the time will be null (or empty).

@rolfbjarne rolfbjarne added this to the d16-3 milestone Jul 8, 2019
@rolfbjarne rolfbjarne merged commit 0ceced2 into xamarin:master Jul 8, 2019
@rolfbjarne
Copy link
Member Author

@monojenkins backport d16-3
@monojenkins backport xcode11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug If an issue is a bug or a pull request a bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NSURLsessionDelegate issues
5 participants