Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Cleanup | Remove More Dead SMI Code (Part 2)#3414

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
benrr101 merged 18 commits intomainfromdev/russellben/cleanup/smi-dead-code2
Jun 18, 2025

Conversation

benrr101
Copy link
Contributor

Description

While working on another chunk of code, I had another breakthrough on provably deleting SMI code. There's a tiny classInOutOfProcHelper that contains a single propertyInProc that always returnsfalse. Pulling on this thread revealed that the entirety of SmiContextFactory and SmiContext could be deleted.

The process I used for safely deleting these was to basically take the hard coded values and propagate them down to lower levels. At each step of propagating, I delete branches of the code became unreachable, and keep pushing it further down. Each commit builds on its own, so it's possible to step through the changes. Trying to explain each step would probably be impossible...

Removing SmiContext from ValueUtilsSmi became a bit tricky since there are circular references that pass an SmiContext between each other. However, knowing that SmiContext should always be null, I was able to work it out by passing null into the calls to the methods, then making the argument have a null default, then eliminating nulls from the calls to the methods, then removing the "internal" usages of the argument since logically they could only be null.

There are a couple annotated spots where the code must've never been called because it will literally always throw.

Testing

These branches should not have been reached previously, so CI should be sufficient validate nothing broke.

…e that false everywhere it was being used to determine what other branches of code can be deleted
…exceptions they will always throw b/c _smiLink will always be null
…sages of the propertyIt can continue to be propagated if we find out the version is always the same...
…nd propagate that forward, allowing us to remove MetadataUtilsSmi.IsValidForSmiVersion and a block of code in SqlDataRecord
…, since it is always passed to itself and is always null
… propagating null to all usages of itAlso removing SqlInternalConnectionSmi.SmiConnection since it's never used.
@benrr101benrr101 added this to the7.0-preview1 milestoneJun 12, 2025
@CopilotCopilotAI review requested due to automatic review settingsJune 12, 2025 04:17
@benrr101benrr101 requested a review froma team as acode ownerJune 12, 2025 04:17
@benrr101benrr101 added the Code Health 💊Issues/PRs that are targeted to source code quality improvements. labelJun 12, 2025
Copy link
Contributor

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request removes dead SMI code and cleans up related internal APIs by eliminating unused SMI context and versioning logic. Key changes include:

  • Removing the InOutOfProcHelper and SmiContext-related branches and entire SmiContextFactory/SmiContext files.
  • Updating SMI utility methods (ValueUtilsSmi and related classes) to no longer require a context parameter.
  • Changing Debug.Assert/Debug.Fail calls and adding TODO markers to signal areas needing further investigation.

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
FileDescription
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlUtil.csAdded a TODO comment to verify method usage.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependency.csRemoved obsolete InProc SMI checks.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ValueUtilsSmi*.csUpdated method signatures and XML documentation to remove context parameters.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SqlDataRecord*.csRemoved branches using SMI context and simplified legacy logic.
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionSmi.csRemoved SMI context usage and updated getters to throw as expected.
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.csReplaced Debug.Assert with Debug.Fail for negotiated SMI version checks.
Other filesRemoved obsolete SMI API files and updated references accordingly.
Comments suppressed due to low confidence (4)

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlUtil.cs:2437

  • [nitpick] Consider expanding this TODO comment with specific criteria or conditions under which these methods should be reviewed or removed to improve clarity for future maintenance.
// @TODO: Check these methods for usage

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs:467

  • [nitpick] Consider replacing Debug.Fail with a more descriptive logging mechanism or a custom exception so that future debugging efforts clearly understand the expected behavior when this condition is encountered.
Debug.Fail("NegotiatedSmiVersion will always throw (SmiContextFactory.Instance.NegotiatedSmiVersion >= SmiContextFactory.Sql2005Version)");

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionSmi.cs:32

  • [nitpick] Add a comment next to this getter to explain why it is expected to always throw, which would help maintainers understand the rationale behind omitting SMI context handling.
get => throw SQL.ContextUnavailableOutOfProc();

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiContextFactory.netfx.cs:1

  • Ensure that all references to SmiContextFactory have been updated and removed to avoid linkage errors or unexpected behavior in the absence of this obsolete API.
// Entire file removed

@edwardneal
Copy link
Contributor

There are a few types which are only ever used from these code paths too.

  • SqlStreamChars
  • SqlClientWrapperSmiStream
  • SqlClientWrapperSmiStreamChars

Besides this, SqlSequentialStreamSmi and SqlSequentialTextReaderSmi will also disappear shortly, once SqlDataReaderSmi is removed.

benrr101 reacted with rocket emoji

@benrr101
Copy link
ContributorAuthor

@edwardneal Very good catch!! Let's get that deleted code counter over 1000!

edwardneal reacted with hooray emoji

@benrr101benrr101 added the Common Project 🚮Things that relate to the common project project labelJun 12, 2025
@codecovCodecov
Copy link

codecovbot commentedJun 12, 2025
edited
Loading

Codecov Report

Attention: Patch coverage is33.85827% with84 lines in your changes missing coverage. Please review.

Project coverage is 65.80%. Comparing base(e649a7c) to head(b214f14).
Report is 8 commits behind head on main.

Files with missing linesPatch %Lines
...x/src/Microsoft/Data/SqlClient/SqlDataReaderSmi.cs0.00%27 Missing⚠️
...osoft/Data/SqlClient/Server/SqlDataRecord.netfx.cs56.41%17 Missing⚠️
...c/Microsoft/Data/SqlClient/Server/ValueUtilsSmi.cs53.84%12 Missing⚠️
...t/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs0.00%10 Missing⚠️
...crosoft/Data/SqlClient/SqlInternalConnectionSmi.cs0.00%7 Missing⚠️
...nt/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs0.00%4 Missing⚠️
...osoft/Data/SqlClient/Server/ValueUtilsSmi.netfx.cs0.00%4 Missing⚠️
...oft/Data/SqlClient/Server/SqlDataRecord.netcore.cs50.00%3 Missing⚠️
Additional details and impacted files
@@            Coverage Diff             @@##             main    #3414      +/-   ##==========================================- Coverage   68.33%   65.80%   -2.53%==========================================  Files         301      294       -7       Lines       65631    65210     -421     ==========================================- Hits        44849    42913    -1936- Misses      20782    22297    +1515
FlagCoverage Δ
addons92.58% <ø> (ø)
netcore68.66% <54.54%> (-3.95%)⬇️
netfx67.36% <33.05%> (+0.36%)⬆️

Flags with carried forward coverage won't be shown.Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report?Share it here.

🚀 New features to boost your workflow:
  • ❄️Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@benrr101benrr101 merged commit9be9a5a intomainJun 18, 2025
251 checks passed
@benrr101benrr101 deleted the dev/russellben/cleanup/smi-dead-code2 branchJune 18, 2025 21:39
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

@mdaiglemdaiglemdaigle approved these changes

@paulmedynskipaulmedynskipaulmedynski approved these changes

@priyankatiwari08priyankatiwari08priyankatiwari08 approved these changes

Assignees
No one assigned
Labels
Code Health 💊Issues/PRs that are targeted to source code quality improvements.Common Project 🚮Things that relate to the common project project
Projects
None yet
Milestone
6.1-preview2
Development

Successfully merging this pull request may close these issues.

5 participants
@benrr101@edwardneal@mdaigle@paulmedynski@priyankatiwari08

[8]ページ先頭

©2009-2025 Movatter.jp