Skip to content

Merge | SqlConfigurableRetryLogicLoader #3246

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

Merged
merged 3 commits into from
Mar 27, 2025

Conversation

benrr101
Copy link
Contributor

Description: Here is the latest merge PR to get us to a single project. This edition brings the netcore SqlConfigurableRetryLogicManager.NetCoreApp.cs and the netfx SqlConfigurableRetryLogicManager.LoadType.cs files into the common project SqlConfigurableRetryLogicLoader class. These files actually contained partial classes of the *Loader class and provided separate implementations of the LoadType functionality.

I also separated interfaces from SqlConfigurableRetryLogicLoader that should be in their own files. Lastly, I started getting carried with stylistic cleanup of the class, but stopped before it went too crazy. I have a follow up PR with those cleanup changes queued up for after this PR.

Testing: Project still builds, no functional changes.

@benrr101 benrr101 added the Common Project 🚮 Things that relate to the common project project label Mar 26, 2025
@benrr101 benrr101 requested review from a team and Copilot March 26, 2025 17:30
Copy link
Contributor

@Copilot Copilot AI 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 PR merges the partial implementations of the SqlConfigurableRetryLogicLoader into a single common class while relocating the configuration interfaces into separate files.

  • Consolidated platform-specific implementations into a unified loader class.
  • Moved and separated configuration interfaces out of the manager file.
  • Removed redundant .NET Core and .NET Framework specific files.

Reviewed Changes

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

Show a summary per file
File Description
ISqlConfigurableRetryConnectionSection.cs Adds interface for connection retry configuration.
IAppContextSwitchOverridesSection.cs Adds interface for AppContext switch overrides.
ISqlConfigurableRetryCommandSection.cs Adds interface for command retry configuration.
SqlConfigurableRetryLogicLoader.cs Consolidates loader logic and implements new assembly resolution and type loading.
SqlConfigurableRetryLogicManager.cs Removes duplicated interface definitions.
SqlConfigurableRetryLogicManager.NetCoreApp.cs Removed redundant .NET Core-specific loader implementation.
SqlConfigurableRetryLogicManager.LoadType.cs Removed redundant .NET Framework-specific loader implementation.
Files not reviewed (2)
  • src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj: Language not supported
  • src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj: Language not supported
Comments suppressed due to low confidence (2)

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Reliability/SqlConfigurableRetryLogicLoader.cs:23

  • The removal of the 'partial' keyword consolidates the class into a single file. Please verify that no essential implementations from other partial class definitions are omitted.
internal sealed class SqlConfigurableRetryLogicLoader

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Reliability/SqlConfigurableRetryLogicLoader.cs:400

  • [nitpick] Consider using AppContext.BaseDirectory instead of Environment.CurrentDirectory in MakeFullPath to ensure a more reliable base path for assembly resolution.
string fullPath = Path.Combine(directory, assemblyName);

namespace Microsoft.Data.SqlClient
{
/// <summary>
/// Configurable retry logic loader
/// This class shouldn't throw exceptions;
/// All exceptions should be handled internally and logged with Event Source.
/// </summary>
internal sealed partial class SqlConfigurableRetryLogicLoader
internal sealed class SqlConfigurableRetryLogicLoader
Copy link
Contributor

Choose a reason for hiding this comment

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

The more I see partial classes, the more I dislike them. Maybe they're just misused a lot in this codebase, but I find them so confusing and troublesome.

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 think they can be very useful, but they need to be sensibly used. I think partial classes, multiple classes in a single file, and filenames that don't correspond to the name of the class make this codebase more difficult to navigate and work on. It's something I want to incrementally resolve as I merge the projects.

In prior projects, I've used partial classes fairly successfully to split classes into logical divisions. Eg, writing an Antlr parser required a single class to handle all the nodes in the syntax tree, so having multiple partial classes to handle logical groupings of node handlers was a necessity. In this project, we have some classes that are so large (my) IDE refuses to do inspection or autocomplete on it (eg, TdsParser). If we have any hope of working on it, we'll likely need to split these up either into multiple classes or into partials.

Anyways ... I digress.

Copy link
Contributor

Choose a reason for hiding this comment

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

From the docs here, the first 'desirable' example is questionable (If you need 2 people in the same file at the same time, maybe you have bigger problems?), and the other 2 examples relate to code generation. I get the feeling partials were added to make development of other MS frameworks easier.

Another somewhat interesting read is here: https://stackoverflow.com/questions/3601901/when-is-it-appropriate-to-use-c-sharp-partial-classes

IMO, if your class is "too big" for a single file, then you need to re-design your class. Sometimes artifically splitting up responsibilities is for the best, even if naturally they're all the domain of a single encapsulation.

OTOH, partial members might be useful for reference packages. Perhaps we declare everything as partial in our ref assembly, and don't provide any definitions. Would that eliminate the need for the "throw" pattern? Food for thought.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@paulmedynski the first desirable sounds more like a holdover from the days of centralized source control (which Microsoft has much history) where having files checked out by multiple people isn't really feasible. I think if you can't comfortably have two engineers in the same file at the same time, you've got bigger problems :)

I don't really subscribe to the "if your class/method is too big you're doing it wrong" school of thought. I think sometimes it makes sense to artificially split things up, sometimes it doesn't. But I see it more of an artform. I'm sure you'll correct me if you think my PRs are bad :P

Copy link

codecov bot commented Mar 26, 2025

Codecov Report

Attention: Patch coverage is 98.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 72.76%. Comparing base (1247ca4) to head (18ee367).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
...ent/Reliability/SqlConfigurableRetryLogicLoader.cs 98.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3246      +/-   ##
==========================================
+ Coverage   72.69%   72.76%   +0.06%     
==========================================
  Files         303      298       -5     
  Lines       59718    59612     -106     
==========================================
- Hits        43414    43377      -37     
+ Misses      16304    16235      -69     
Flag Coverage Δ
addons 92.58% <ø> (ø)
netcore 75.24% <97.77%> (+0.13%) ⬆️
netfx 71.37% <100.00%> (-0.02%) ⬇️

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.

@paulmedynski paulmedynski self-assigned this Mar 27, 2025
@benrr101 benrr101 merged commit b2ee435 into main Mar 27, 2025
252 checks passed
@benrr101 benrr101 deleted the dev/russellben/merge/sqlconfigurableretrylogicmanager branch March 27, 2025 19:11
@cheenamalhotra cheenamalhotra added this to the 6.1-preview1 milestone Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Common Project 🚮 Things that relate to the common project project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy