-
Notifications
You must be signed in to change notification settings - Fork 297
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
Updates for .NET 8 code analysis - Part 1 #1443
Updates for .NET 8 code analysis - Part 1 #1443
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1443 +/- ##
==========================================
- Coverage 73.91% 73.67% -0.24%
==========================================
Files 267 261 -6
Lines 9615 9687 +72
==========================================
+ Hits 7107 7137 +30
- Misses 2508 2550 +42
Flags with carried forward coverage won't be shown. Click here to find out more.
|
…/github.com/utpilla/opentelemetry-dotnet-contrib into utpilla/Update-projects-for-code-analysis-1
#if NET7_0_OR_GREATER | ||
ObjectDisposedException.ThrowIf(this.disposed, nameof(CallbackManager<T>)); | ||
#else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now we have only one place, so it is fine. Consider to extend Guard class with implementation for ThrowIfObjectDisposedExcpetion(bool disposed, Type type)
#if NET6_0_OR_GREATER | ||
int idx = websiteOwnerName.IndexOf('+', StringComparison.Ordinal); | ||
#else | ||
int idx = websiteOwnerName.IndexOf("+", StringComparison.Ordinal); | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From current implementation:
public int IndexOf(char value, StringComparison comparisonType)
{
switch (comparisonType)
{
case StringComparison.CurrentCulture:
case StringComparison.CurrentCultureIgnoreCase:
return CultureInfo.CurrentCulture.CompareInfo.IndexOf(this, value, GetCaseCompareOfComparisonCulture(comparisonType));
case StringComparison.InvariantCulture:
case StringComparison.InvariantCultureIgnoreCase:
return CompareInfo.Invariant.IndexOf(this, value, GetCaseCompareOfComparisonCulture(comparisonType));
case StringComparison.Ordinal:
return IndexOf(value);
case StringComparison.OrdinalIgnoreCase:
return CompareInfo.Invariant.IndexOf(this, value, CompareOptions.OrdinalIgnoreCase);
default:
throw new ArgumentException(SR.NotSupported_StringComparison, nameof(comparisonType));
}
It should allow remove conditional compilation
#if NET6_0_OR_GREATER | |
int idx = websiteOwnerName.IndexOf('+', StringComparison.Ordinal); | |
#else | |
int idx = websiteOwnerName.IndexOf("+", StringComparison.Ordinal); | |
#endif | |
int idx = websiteOwnerName.IndexOf('+'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to not rely on the implementation details here. It would be fine to use IndexOf('+')
today but .NET team is free to change the implementation in .NET 9 or later.
@@ -202,7 +202,9 @@ internal BaseProcessor<LogRecord> BuildProcessor() | |||
|
|||
private OneCollectorExporter<LogRecord> BuildExporter() | |||
{ | |||
#pragma warning disable CA2000 // Dispose objects before losing scope |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: You could try renaming this method "CreateExporter" it may resolve CA2000. It tries to use names of things to detect factory patterns where it is expected that something will be returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that but it didn't help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Towards #1437
Changes
System.Net.Http