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

Clean: Modernize style in ValueUtilsSmi #1351

Merged
merged 5 commits into from
Feb 25, 2022
Merged

Conversation

Wraith2
Copy link
Contributor

@Wraith2 Wraith2 commented Oct 15, 2021

A whole lot of style changes with one fix for a programming error which I'll highlight in the code.
In future it might be worth creating a bitmap like BitArray for the read write bool maps, they're currently quite wasteful of memory.

@Wraith2 Wraith2 force-pushed the clean-valueutils branch 2 times, most recently from d2b8e8e to 09cf9e8 Compare October 17, 2021 12:55
@Wraith2
Copy link
Contributor Author

Wraith2 commented Oct 17, 2021

I've cleaned up the majority of the #ifdefs by using a conditional alias to set SmiContext to object in netcore builds. The context is almost never used even in netcore and anywhere that actually needs it to be the real type wouldn't compile with the object alias. This unifies the majority of the file, see what you think @Kaur-Parminder

@cheenamalhotra cheenamalhotra added the ➕ Code Health Issues/PRs that are targeted to source code quality improvements. label Oct 25, 2021
@Kaur-Parminder
Copy link
Contributor

I've cleaned up the majority of the #ifdefs by using a conditional alias to set SmiContext to object in netcore builds. The context is almost never used even in netcore and anywhere that actually needs it to be the real type wouldn't compile with the object alias. This unifies the majority of the file, see what you think @Kaur-Parminder

@Wraith2 changes look good to me.

@Wraith2
Copy link
Contributor Author

Wraith2 commented Jan 19, 2022

Merge conflicts resolved.


// Central checkpoint for closed recordset.
// Any code that requires an open recordset should call this method first!
// Especially any code that accesses unmanaged memory structures whose lifetime
// matches the lifetime of the unmanaged recordset.
internal void ThrowIfClosed(string operationName)
internal void ThrowIfClosed([CallerMemberName] string operationName = null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Although operationName is not going to be null there might be an exception thrown for assigning null value as a default value. shouldn't we use #nullable enable and disable here and change it to string? operationName =null or as MS documents shows assign an empty string to operationName?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We aren't using nullable contexts anywhere in this library yet. When we do then it'll be picked up as we have to go over the library to annotate it. It doesn't seem helpful until then.

typeCode == ExtendedClrTypeCode.DBNull ||
typeCode == ExtendedClrTypeCode.Empty ||
CanAccessSetterDirectly(metaData, typeCode) ||
value is DataFeed
Copy link
Contributor

@JRahnama JRahnama Feb 23, 2022

Choose a reason for hiding this comment

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

NIT: can we put the comment back as well, I have found those comments very helpful while debugging an issue.

}

// Central checkpoint to ensure the requested column can be accessed.
// Calling this function serves to notify that it has been accessed by the user.
[SuppressMessage("Microsoft.Performance", "CA1801:AvoidUnusedParameters")] // for future compatibility
private void EnsureCanGetCol(string operationName, int ordinal)
private void EnsureCanGetCol(int ordinal, [CallerMemberName] string operationName = null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Two things rule CA1801 has been deprecated in favor of IDE0060.
Second why do we need the unused variable int ordinal at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll replace CA1801 with IDE0060. Why do we need that ordinal parameter? no idea, I'd have thought we'd want to report which column we failed to get but it doesn't currently do that and I'm not trying to fixup new issues just get the codebases merged.

@JRahnama
Copy link
Contributor

Also can you address the conflict please?

@JRahnama
Copy link
Contributor

the failures are related to your changes. Can you check that please?

@Wraith2
Copy link
Contributor Author

Wraith2 commented Feb 23, 2022

Done. I thought the CI wasn't working, it doesn't seem to run any of the version specific legs any more.

@JRahnama JRahnama merged commit a359a18 into dotnet:main Feb 25, 2022
@Wraith2 Wraith2 deleted the clean-valueutils branch February 25, 2022 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
➕ Code Health Issues/PRs that are targeted to source code quality improvements.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants