Skip to content

Commit 2693b26

Browse files
feat: net5 for sentry.csproj (#589)
Co-authored-by: Bruno Garcia <[email protected]>
1 parent 064cfc3 commit 2693b26

25 files changed

+119
-62
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## vNext
44

5+
* Add target framework NET5.0 on Sentry.csproj. Change the type of `Extra` where value parameter become nullable. @lucas-zimerman
56
* Implement envelope caching. (#576) @Tyrrrz
67
* Add a list of .NET Frameworks installed when available. (#531) @lucas-zimerman
78
* Parse Mono and IL2CPP stacktraces for Unity and Xamarin (#578) @bruno-garcia

samples/Sentry.Samples.Console.Customized/Sentry.Samples.Console.Customized.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFrameworks>netcoreapp2.1;net472</TargetFrameworks>
5+
<TargetFrameworks>net5.0;netcoreapp2.1;net472</TargetFrameworks>
66
<!--Set explicitly to demonstrate one way of defining the Sentry Release-->
77
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
88
</PropertyGroup>

src/Sentry.Log4Net/SentryAppender.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ protected override void Append(LoggingEvent loggingEvent)
127127
_ = Hub.CaptureEvent(evt);
128128
}
129129

130-
private static IEnumerable<KeyValuePair<string, object>> GetLoggingEventProperties(LoggingEvent loggingEvent)
130+
private static IEnumerable<KeyValuePair<string, object?>> GetLoggingEventProperties(LoggingEvent loggingEvent)
131131
{
132132
var properties = loggingEvent.GetProperties();
133133
if (properties == null)
@@ -144,7 +144,7 @@ private static IEnumerable<KeyValuePair<string, object>> GetLoggingEventProperti
144144
if (value != null
145145
&& (!(value is string stringValue) || !string.IsNullOrWhiteSpace(stringValue)))
146146
{
147-
yield return new KeyValuePair<string, object>(key, value);
147+
yield return new KeyValuePair<string, object?>(key, value);
148148
}
149149
}
150150
}
@@ -154,38 +154,38 @@ private static IEnumerable<KeyValuePair<string, object>> GetLoggingEventProperti
154154
{
155155
if (!string.IsNullOrEmpty(locInfo.ClassName))
156156
{
157-
yield return new KeyValuePair<string, object>(nameof(locInfo.ClassName), locInfo.ClassName);
157+
yield return new KeyValuePair<string, object?>(nameof(locInfo.ClassName), locInfo.ClassName);
158158
}
159159

160160
if (!string.IsNullOrEmpty(locInfo.FileName))
161161
{
162-
yield return new KeyValuePair<string, object>(nameof(locInfo.FileName), locInfo.FileName);
162+
yield return new KeyValuePair<string, object?>(nameof(locInfo.FileName), locInfo.FileName);
163163
}
164164

165165
if (int.TryParse(locInfo.LineNumber, out var lineNumber) && lineNumber != 0)
166166
{
167-
yield return new KeyValuePair<string, object>(nameof(locInfo.LineNumber), lineNumber);
167+
yield return new KeyValuePair<string, object?>(nameof(locInfo.LineNumber), lineNumber);
168168
}
169169

170170
if (!string.IsNullOrEmpty(locInfo.MethodName))
171171
{
172-
yield return new KeyValuePair<string, object>(nameof(locInfo.MethodName), locInfo.MethodName);
172+
yield return new KeyValuePair<string, object?>(nameof(locInfo.MethodName), locInfo.MethodName);
173173
}
174174
}
175175

176176
if (!string.IsNullOrEmpty(loggingEvent.ThreadName))
177177
{
178-
yield return new KeyValuePair<string, object>(nameof(loggingEvent.ThreadName), loggingEvent.ThreadName);
178+
yield return new KeyValuePair<string, object?>(nameof(loggingEvent.ThreadName), loggingEvent.ThreadName);
179179
}
180180

181181
if (!string.IsNullOrEmpty(loggingEvent.Domain))
182182
{
183-
yield return new KeyValuePair<string, object>(nameof(loggingEvent.Domain), loggingEvent.Domain);
183+
yield return new KeyValuePair<string, object?>(nameof(loggingEvent.Domain), loggingEvent.Domain);
184184
}
185185

186186
if (loggingEvent.Level != null)
187187
{
188-
yield return new KeyValuePair<string, object>("log4net-level", loggingEvent.Level.Name);
188+
yield return new KeyValuePair<string, object?>("log4net-level", loggingEvent.Level.Name);
189189
}
190190
}
191191

src/Sentry.Serilog/SentrySink.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public void Emit(LogEvent logEvent)
136136
}
137137
}
138138

139-
private IEnumerable<KeyValuePair<string, object>> GetLoggingEventProperties(LogEvent logEvent)
139+
private IEnumerable<KeyValuePair<string, object?>> GetLoggingEventProperties(LogEvent logEvent)
140140
{
141141
var properties = logEvent.Properties;
142142

@@ -145,11 +145,11 @@ private IEnumerable<KeyValuePair<string, object>> GetLoggingEventProperties(LogE
145145
var value = property.Value;
146146
if (value is ScalarValue scalarValue)
147147
{
148-
yield return new KeyValuePair<string, object>(property.Key, scalarValue.Value);
148+
yield return new KeyValuePair<string, object?>(property.Key, scalarValue.Value);
149149
}
150150
else if (value != null)
151151
{
152-
yield return new KeyValuePair<string, object>(property.Key, value);
152+
yield return new KeyValuePair<string, object?>(property.Key, value);
153153
}
154154
}
155155
}

src/Sentry/Extensibility/DefaultRequestPayloadExtractor.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ public class DefaultRequestPayloadExtractor : BaseRequestPayloadExtractor
1818
/// </summary>
1919
protected override object? DoExtractPayLoad(IHttpRequest request)
2020
{
21+
if(request.Body is null)
22+
{
23+
return null;
24+
}
2125
// https://github.com/dotnet/corefx/blob/master/src/Common/src/CoreLib/System/IO/StreamReader.cs#L186
2226
// Default parameters other than 'leaveOpen'
2327
using var reader = new StreamReader(request.Body, Encoding.UTF8, true, 1024,

src/Sentry/Extensibility/SentryStackTraceFactory.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ protected SentryStackFrame InternalCreateFrame(StackFrame stackFrame, bool deman
163163
/// Get a <see cref="MethodBase"/> from <see cref="StackFrame"/>.
164164
/// </summary>
165165
/// <param name="stackFrame">The <see cref="StackFrame"/></param>.
166-
protected virtual MethodBase GetMethod(StackFrame stackFrame) => stackFrame.GetMethod();
166+
protected virtual MethodBase? GetMethod(StackFrame stackFrame)
167+
=> stackFrame.GetMethod();
167168

168169
private bool IsSystemModuleName(string? moduleName)
169170
{

src/Sentry/Integrations/AppDomainProcessExitIntegration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void Unregister(IHub hub)
2727
_hub = null;
2828
}
2929

30-
internal void HandleProcessExit(object sender, EventArgs e)
30+
internal void HandleProcessExit(object? sender, EventArgs e)
3131
{
3232
(_hub as IDisposable)?.Dispose();
3333
}

src/Sentry/Integrations/TaskUnobservedTaskExceptionIntegration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void Unregister(IHub hub)
2929

3030
// Internal for testability
3131
[HandleProcessCorruptedStateExceptions, SecurityCritical]
32-
internal void Handle(object sender, UnobservedTaskExceptionEventArgs e)
32+
internal void Handle(object? sender, UnobservedTaskExceptionEventArgs e)
3333
{
3434
if (e.Exception != null)
3535
{

src/Sentry/Internal/AppDomainAdapter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ private AppDomainAdapter()
3131

3232
public event EventHandler<UnobservedTaskExceptionEventArgs>? UnobservedTaskException;
3333

34-
private void OnProcessExit(object sender, EventArgs e) => ProcessExit?.Invoke(sender, e);
34+
private void OnProcessExit(object? sender, EventArgs e) => ProcessExit?.Invoke(sender, e);
3535

3636
[HandleProcessCorruptedStateExceptions, SecurityCritical]
3737
private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e) => UnhandledException?.Invoke(this, e);
3838

3939
[HandleProcessCorruptedStateExceptions, SecurityCritical]
40-
private void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) => UnobservedTaskException?.Invoke(this, e);
40+
private void OnUnobservedTaskException(object? sender, UnobservedTaskExceptionEventArgs e) => UnobservedTaskException?.Invoke(this, e);
4141
}
4242
}

src/Sentry/Internal/BackgroundWorker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public async ValueTask FlushAsync(TimeSpan timeout)
207207
var counter = 0;
208208
var depth = int.MaxValue;
209209

210-
void EventFlushedCallback(object objProcessed, EventArgs _)
210+
void EventFlushedCallback(object? _, EventArgs __)
211211
{
212212
// ReSharper disable once AccessToModifiedClosure
213213
if (Interlocked.Increment(ref counter) >= depth)

0 commit comments

Comments
 (0)