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

Replace calls to Method.GetCurrentMethod().Name with nameof() #1943

Merged
merged 4 commits into from Mar 21, 2023

Conversation

kant2002
Copy link
Contributor

@kant2002 kant2002 commented Mar 5, 2023

That reduce places which marked as trimmer unfriendly. Even if Method.CurrentMethod().Name will work after trimming, but tooling cannot decide that in generic cases, see: dotnet/runtime#53242 At this point I would like to replace formatting primitives with $"" if possible, since that allow Rolsyn build constant string for us at compile time.

Also enabled Trim Analyzer on the build, so all trim warnings can be gradually removed after proper annotations, or other work done.

/cc @Wraith2

That reduce places which marked as trimmer unfriendly. Even if `Method.CurrentMethod().Name` will work after trimming, but tooling cannot decide that in generic cases, see: dotnet/runtime#53242
At this point I would like to replace formatting primitives with `$""` if possible, since that allow Rolsyn manually build constant string.

Also enabled Trim Analyzer on the build, so all trim warnings can be gradually removed after proper annotations, or other work done.

/cc @Wraith2
@@ -30,7 +30,7 @@ static LocalAppContextSwitches()
catch (Exception e)
{
// Don't throw an exception for an invalid config file
SqlClientEventSource.Log.TryTraceEvent("<sc.{0}.{1}|INFO>: {2}", TypeName, MethodBase.GetCurrentMethod().Name, e);
SqlClientEventSource.Log.TryTraceEvent("<sc.{0}.{1}|INFO>: {2}", TypeName, "..ctor", e);
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be .cctor for a static constructor?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, can you inline the TypeName, it's a nameof in a variable which is a bit pointless when it's single use.

@DavoudEshtehari DavoudEshtehari added ➕ Code Health Changes related to source code improvements and removed 💡 Enhancement New feature request labels Mar 15, 2023
@codecov
Copy link

codecov bot commented Mar 15, 2023

Codecov Report

Patch coverage: 90.00% and project coverage change: -1.84 ⚠️

Comparison is base (73c6b2f) 71.53% compared to head (7d55d47) 69.69%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1943      +/-   ##
==========================================
- Coverage   71.53%   69.69%   -1.84%     
==========================================
  Files         306      306              
  Lines       61841    61563     -278     
==========================================
- Hits        44235    42909    -1326     
- Misses      17606    18654    +1048     
Flag Coverage Δ
addons 92.38% <ø> (ø)
netcore 73.20% <89.47%> (-2.50%) ⬇️
netfx 67.96% <100.00%> (-1.15%) ⬇️

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

Impacted Files Coverage Δ
...icrosoft/Data/SqlClient/LocalAppContextSwitches.cs 56.25% <0.00%> (ø)
...SqlClient/SqlAppContextSwitchManager.NetCoreApp.cs 23.80% <50.00%> (ø)
...ity/SqlConfigurableRetryLogicManager.NetCoreApp.cs 100.00% <100.00%> (ø)
...e/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs 61.85% <100.00%> (-0.78%) ⬇️
...ility/SqlConfigurableRetryLogicManager.LoadType.cs 100.00% <100.00%> (ø)
...oft/Data/SqlClient/Reliability/AppConfigManager.cs 68.57% <100.00%> (ø)
...Data/SqlClient/Reliability/Common/SqlRetryLogic.cs 100.00% <100.00%> (ø)
...Client/Reliability/Common/SqlRetryLogicProvider.cs 89.13% <100.00%> (-2.18%) ⬇️
...lClient/Reliability/SqlConfigurableRetryFactory.cs 100.00% <100.00%> (ø)
...ent/Reliability/SqlConfigurableRetryLogicLoader.cs 85.48% <100.00%> (ø)

... and 42 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@lcheunglci
Copy link
Contributor

The changes looks good to me. Thanks @kant2002 for your contributions

@lcheunglci lcheunglci merged commit 1bcdb23 into dotnet:main Mar 21, 2023
131 checks passed
@kant2002 kant2002 deleted the kant/remove-currentmethod-usages branch March 21, 2023 16:45
@lcheunglci lcheunglci mentioned this pull request Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
➕ Code Health Changes related to source code improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants