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

ASPNET.Core default Environment settings are cleaned, if used. #554

Merged

Conversation

PureKrome
Copy link
Contributor

@PureKrome PureKrome commented Oct 18, 2020

Resolves #551

NOTES:

The ASPNET.Core project actually targets both NETCOREAPP30 and NS20 (I'm not sure why .....).

<TargetFrameworks>netcoreapp3.0;netstandard2.0</TargetFrameworks>

As such, I've ended up NOT doing a single "if environment == "Production" string check (for both NS20 and NCA30) because NETCOREAPP30+ now includes this string as a constant. Yay 🎉

So I ended up using #if NETSTANDARD2_0 etc, preprocessor directives. It makes the code a bit more messy, so i'm totally happy to strip that out and just have the a simple string check for both, instead of a string check and a const string check.

Finally, not sure if the test I added was into the correct file, etc. So happy to get told otherwise.

@PureKrome PureKrome changed the title ASPNET Core default Environment settings are cleaned, if used. ASPNET.Core default Environment settings are cleaned, if used. Oct 18, 2020
@PureKrome
Copy link
Contributor Author

@bruno-garcia Drats - the test failed, yet it works on my machine. Is there any way I can see what the failure is?

(BTW, I can't run any NET461 or NC21 tests on my machine. I only have NetCore3+ installed)

image

Not sure if the failing test occurs there/then?

@codecov-io
Copy link

codecov-io commented Oct 18, 2020

Codecov Report

Merging #554 into main will decrease coverage by 0.09%.
The diff coverage is 86.25%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #554      +/-   ##
==========================================
- Coverage   85.33%   85.23%   -0.10%     
==========================================
  Files         128      138      +10     
  Lines        3170     3332     +162     
  Branches      730      752      +22     
==========================================
+ Hits         2705     2840     +135     
- Misses        268      294      +26     
- Partials      197      198       +1     
Impacted Files Coverage Δ
src/Sentry/Protocol/BaseScopeExtensions.cs 86.66% <ø> (ø)
src/Sentry/Protocol/Context/Contexts.cs 90.90% <ø> (ø)
src/Sentry/Protocol/Request.cs 92.00% <ø> (ø)
src/Sentry/Internal/Polyfills.cs 50.00% <50.00%> (ø)
src/Sentry/Protocol/EnvelopeItem.cs 60.00% <60.00%> (ø)
src/Sentry/Protocol/StreamSerializable.cs 66.66% <66.66%> (ø)
src/Sentry/SentryClient.cs 80.45% <66.66%> (-2.10%) ⬇️
src/Sentry/Internal/Http/HttpTransport.cs 89.47% <88.88%> (+2.80%) ⬆️
src/Sentry/Internal/BackgroundWorker.cs 84.28% <93.18%> (+0.82%) ⬆️
src/Sentry/Protocol/Envelope.cs 96.15% <96.15%> (ø)
... and 26 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update efeab33...890c095. Read the comment docs.

@PureKrome
Copy link
Contributor Author

PureKrome commented Oct 19, 2020

@bruno-garcia as a side note to this PR, i don't understand how my PR dropped that files code coverage by 8% 😢

I'd love to know how/why so I can make sure I'm covering the code I just created.

(note: I did click on the file in the codecoverage report above and not sure how to make it out :/ )

@Tyrrrz
Copy link
Contributor

Tyrrrz commented Oct 19, 2020

The ASPNET.Core project actually targets both NETCOREAPP30 and NS20 (I'm not sure why .....).

That's mainly because NS20 doesn't have nullable type annotations on BCL. NS20 is still required for older versions of the framework, I'm guessing.

i don't understand how my PR dropped that files code coverage by 8%

That was probably outdated, shows +0.04% now.

src/Sentry.AspNetCore/SentryAspNetCoreOptionsSetup.cs Outdated Show resolved Hide resolved
// need to respect (especially the case-sensitivity).
// REF: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments
#if NETSTANDARD2_0
if (_hostingEnvironment.EnvironmentName.Equals("Production"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we consider case sensitivity here? Or maybe use StringComparison.OrdinalIgnoreCase?

Copy link
Contributor Author

@PureKrome PureKrome Oct 19, 2020

Choose a reason for hiding this comment

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

re: exact casing:

I did case sensitivity to reduce cycles. Why set the value if it's already the exact same?

EDIT: Also not sure if there's an extra allocation if setting the string value, if the previous string value is already the same.

src/Sentry.AspNetCore/SentryAspNetCoreOptionsSetup.cs Outdated Show resolved Hide resolved
Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

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

great stuff!

src/Sentry.AspNetCore/SentryAspNetCoreOptionsSetup.cs Outdated Show resolved Hide resolved
src/Sentry.AspNetCore/SentryAspNetCoreOptionsSetup.cs Outdated Show resolved Hide resolved
@PureKrome PureKrome force-pushed the 551/aspnet-core-fix-environment-settings branch from 40ad2f5 to f426efd Compare October 19, 2020 22:04
@PureKrome
Copy link
Contributor Author

sadness 😢 AppVeyor is dying cause of some transient error :(

  Determining projects to restore...
C:\projects\sentry-dotnet\.tmp\dotnet\sdk\5.0.100-preview.8.20417.9\NuGet.targets(128,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\projects\sentry-dotnet\Sentry.sln]
C:\projects\sentry-dotnet\.tmp\dotnet\sdk\5.0.100-preview.8.20417.9\NuGet.targets(128,5): error :   No connection could be made because the target machine actively refused it. (api.nuget.org:443) [C:\projects\sentry-dotnet\Sentry.sln]
C:\projects\sentry-dotnet\.tmp\dotnet\sdk\5.0.100-preview.8.20417.9\NuGet.targets(128,5): error :   No connection could be made because the target machine actively refused it. [C:\projects\sentry-dotnet\Sentry.sln]
Command exited with code 1
bash scripts\zeus.sh report_failed

@bruno-garcia
Copy link
Member

rerunning the build.
We'll hopefully soon move over to GHA completely

Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

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

Good stuff!

@bruno-garcia bruno-garcia merged commit 5d76498 into getsentry:main Oct 20, 2020
@bruno-garcia
Copy link
Member

Thanks again @PureKrome !

@PureKrome
Copy link
Contributor Author

My pleasure 👍🏻

@PureKrome PureKrome deleted the 551/aspnet-core-fix-environment-settings branch September 2, 2022 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ASPNET.Core should use 'production' or 'development' for their default Environment settings
5 participants