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

OleDbConnectionInternal.BuildInfoLiterals should return non-null #44288

Closed
krwq opened this issue Nov 5, 2020 · 5 comments
Closed

OleDbConnectionInternal.BuildInfoLiterals should return non-null #44288

krwq opened this issue Nov 5, 2020 · 5 comments

Comments

@krwq
Copy link
Member

krwq commented Nov 5, 2020

This method itself is internal but it affects annotations of couple of public methods.

OleDbConnectionInternal.BuildInfoLiterals code suggests that:

                if (null == dbInfo)
                {
                    return null;
                }

is likely a dead code since dbInfo is annotated as non-nullable which suggests this method will never return null.

Found when applying nullable annotations

@ghost
Copy link

ghost commented Nov 5, 2020

Tagging subscribers to this area: @roji, @ajcvickers
See info in area-owners.md if you want to be subscribed.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Nov 5, 2020
@ajcvickers ajcvickers removed the untriaged New issue has not been triaged by the area owner label Jul 13, 2021
@ajcvickers ajcvickers added this to the 6.0.0 milestone Jul 13, 2021
@ajcvickers
Copy link
Contributor

@roji Can you take a look at this along with the other nullability tweaks?

@roji
Copy link
Member

roji commented Jul 13, 2021

Yep, already on my list.

@roji
Copy link
Member

roji commented Jul 14, 2021

The pattern of doing:

UnsafeNativeMethods.IDBInfo dbInfo = wrapper.Value;
if (null == dbInfo)
{
    return false;
}

... seems common in the codebase, e.g. AddInfoKeywordsToTable does this as well. dbInfo is assigned from IDbInfoWrapper._value, which comes from native COM components; I suspect null would only be observed in some sort of error condition, but I simply don't know enough about OleDB/COM to be sure... So it seems a bit risky to assume that dbInfo is never null.

Note also that OleDbConnection.GetOleDbSchemaTable - the public method wrapping BuildInfoLiterals - also needs to return null because of GetSchemaRowset, which is also annotated to return null. There as well, the rowset variable is assigned by native code and compared to null; this could again be dead code, but we'd have to dive into the native code to be sure.

So given that this is effectively legacy code, and to be on the safe side, it seems better to leave this annotated as nullable... @krwq thoughts?

@ajcvickers
Copy link
Contributor

Closing this as by-design. Can re-open if @krwq has any input.

@ajcvickers ajcvickers removed this from the 6.0.0 milestone Aug 2, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Sep 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants