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

fix: #9 Fix warnings #12

Merged
merged 26 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Raygun.NetCore.Blazor.Server/Class1.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace Raygun.NetCore.Blazor.Server

Choose a reason for hiding this comment

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

I imagine we'll just want to delete this class

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 thought the same, the Raygun.Blazor.Server question is addressed here: #22

{
/// <summary>
///
/// </summary>
public class Class1
{

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Microsoft.AspNetCore.Builder
namespace Raygun.NetCore.Blazor.Server.Extensions
{

/// <summary>
///
/// </summary>
public static class HostBuilderExtensions
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting
/// <summary>
/// Extensions for registering RaygunBlazorClient and related services with a Blazor WebAssembly application.
/// </summary>
public static class Raygun_WebAssembly_WebAssemblyHostBuilderExtensions
public static class RaygunWebAssemblyWebAssemblyHostBuilderExtensions
miquelbeltran marked this conversation as resolved.
Show resolved Hide resolved
{

/// <summary>
Expand Down Expand Up @@ -44,7 +44,7 @@ public static void UseRaygunBlazor(this WebAssemblyHostBuilder builder, string c
var raygunSettings = sp.GetRequiredService<IOptions<RaygunSettings>>().Value;
client.BaseAddress = new Uri(raygunSettings.Endpoint);
client.DefaultRequestHeaders.Add("X-ApiKey", raygunSettings.ApiKey);
client.DefaultRequestHeaders.CacheControl = Raygun_Blazor_IServiceCollectionExtensions.CacheControlHeaderValue;
client.DefaultRequestHeaders.CacheControl = RaygunBlazorIServiceCollectionExtensions.CacheControlHeaderValue;
// TODO: RWM: Set user agent
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace System.Diagnostics
/// <summary>
/// Extension methods for the <see cref="EnhancedStackTrace" /> class.
/// </summary>
internal static class Raygun_Blazor_EnhancedStackTraceExtensions
internal static class RaygunBlazorEnhancedStackTraceExtensions
{

/// <summary>
Expand All @@ -23,7 +23,7 @@ internal static IEnumerable<StackFrame> GetExternalFrames(this EnhancedStackTrac
// incorrectly exclude classes if someone else creates classes in their own code that match our class names,
// OR changes the namespace of the Raygun4NetCore classes.
return stackTrace.GetFrames()
.Where(c => c.GetMethod().DeclaringType.Assembly.FullName != typeof(Raygun_Blazor_EnhancedStackTraceExtensions).Assembly.FullName);
.Where(c => c.GetMethod()?.DeclaringType?.Assembly.FullName != typeof(RaygunBlazorEnhancedStackTraceExtensions).Assembly.FullName);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <summary>
/// Extension methods for adding Raygun components to Dependency Injection <see cref="IServiceCollection" /> containers.
/// </summary>
public static class Raygun_Blazor_IServiceCollectionExtensions
public static class RaygunBlazorIServiceCollectionExtensions
{

#region Static Fields
Expand Down
10 changes: 6 additions & 4 deletions src/Raygun.NetCore.Blazor/Extensions/StackFrameExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace System.Diagnostics
/// <summary>
/// Extension methods for the <see cref="StackFrame" /> class.
/// </summary>
internal static class Raygun_Blazor_StackFrameExtensions
internal static class RaygunBlazorStackFrameExtensions
{

/// <summary>
Expand All @@ -22,16 +22,18 @@ internal static class Raygun_Blazor_StackFrameExtensions
/// both the class and method names in the type name, and the reported method name will be "MoveNext" for async methods.
/// Obviously this is totally unhelpful for developers, so we need to make it more magical.
/// </remarks>
public static (string ClassName, string MethodName) GetBlazorNames(this StackFrame stackFrame)
public static (string? ClassName, string? MethodName) GetBlazorNames(this StackFrame stackFrame)
{
var method = stackFrame.GetMethod();
var declaringTypeName = method.DeclaringType.FullName;
if (method == null) return (null, null);
var declaringTypeName = method.DeclaringType?.FullName;
if (declaringTypeName == null) return (null, method.Name);
var isBlazorType = declaringTypeName.Contains("+<");

return isBlazorType ?
// RWM: If we're in a .razor file, the real type name will be one level up on the inheritance chain,
// while the real method name will be embedded in the current type's name. Fun!
(method.DeclaringType.DeclaringType.FullName, NamingUtilities.GetBlazorMethodName(declaringTypeName).ToString()) :
(method.DeclaringType?.DeclaringType?.FullName, NamingUtilities.GetBlazorMethodName(declaringTypeName).ToString()) :
// RWM: Otherwise, we're in a normal class, so we can just use the type and method names as-is.
(declaringTypeName, method.Name);
}
Expand Down
14 changes: 7 additions & 7 deletions src/Raygun.NetCore.Blazor/Models/BreadcrumbDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ internal record BreadcrumbDetails
/// A custom value used to arbitrarily group this Breadcrumb.
/// </summary>
[JsonInclude]
public string Category { get; set; }
public string? Category { get; set; }

/// <summary>
/// If relevant, a class name from where the breadcrumb was recorded.
/// </summary>
[JsonInclude]
public string ClassName { get; internal set; }
public string? ClassName { get; internal set; }

/// <summary>
/// Any custom data you want to record about application state when the Breadcrumb was recorded.
/// </summary>
[JsonInclude]
public Dictionary<string, object> CustomData { get; set; }
public Dictionary<string, object>? CustomData { get; set; }

/// <summary>
/// If relevant, a line number from where the breadcrumb was recorded.
Expand All @@ -47,18 +47,18 @@ internal record BreadcrumbDetails
/// The message you want to record for this Breadcrumb.
/// </summary>
[JsonInclude]
public string Message { get; set; }
public string? Message { get; set; }

/// <summary>
/// If relevant, a method name from where the Breadcrumb was recorded.
/// </summary>
[JsonInclude]
public string MethodName { get; internal set; }
public string? MethodName { get; internal set; }

/// <summary>
/// Specifies the platform that the breadcrumb was recorded on. Possible values are "DotNet", and "JavaScript.
/// </summary>
public string Platform { get; set; }
public string? Platform { get; set; }

/// <summary>
/// Milliseconds since the Unix Epoch.
Expand Down Expand Up @@ -97,7 +97,7 @@ private BreadcrumbDetails()
/// <param name="category">A custom value used to arbitrarily group this Breadcrumb.</param>
/// <param name="customData">Any custom data you want to record about application state when the breadcrumb was recorded.</param>
/// <param name="platform">Specifies the platform that the breadcrumb was recorded on. Possible values are "DotNet", and "JavaScript.</param>
public BreadcrumbDetails(string message, BreadcrumbType type = BreadcrumbType.Manual, string category = null, Dictionary<string, object> customData = null, string platform = "DotNet")
public BreadcrumbDetails(string? message, BreadcrumbType type = BreadcrumbType.Manual, string? category = null, Dictionary<string, object>? customData = null, string? platform = "DotNet")
{
Message = message;
Type = type;
Expand Down
40 changes: 19 additions & 21 deletions src/Raygun.NetCore.Blazor/Models/BrowserSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ internal record BrowserSpecs
{
#region Private Members

private string calculatedBrowserVersion;
private string calculatedBrowserName;
private string calculatedOSVersion;
private string deviceModel;
private string deviceName;
private string browserManufacturer;
private string? _calculatedBrowserVersion;
private string? _calculatedBrowserName;
private string? _calculatedOSVersion;
// private string? _browserManufacturer;

Choose a reason for hiding this comment

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

Should delete this unless we intend to wire it up

Copy link
Contributor

Choose a reason for hiding this comment

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

At one point I had intended to wire those up from the UserAgentHints, but then I discovered that the versioning at that level is a dictionary of multiple sets of values, including an extra key designed to throw off people doing things like this.

So I believe I decided to return the whole array (minus the BS extra key) instead, which means those can be deleted.


#endregion

Expand All @@ -33,12 +31,12 @@ internal record BrowserSpecs
/// <summary>
///
/// </summary>
public string CalculatedBrowserName => calculatedBrowserName;
public string? CalculatedBrowserName => _calculatedBrowserName;

/// <summary>
///
/// </summary>
public string CalculatedBrowserVersion => calculatedBrowserVersion;
public string? CalculatedBrowserVersion => _calculatedBrowserVersion;

/// <summary>
///
Expand All @@ -48,22 +46,22 @@ internal record BrowserSpecs
/// <summary>
///
/// </summary>
public string DeviceManufacturer { get; set; }
public string? DeviceManufacturer { get; set; }

/// <summary>
///
/// </summary>
public string DeviceModel => deviceModel;
public string? DeviceModel { get; set; }

/// <summary>
///
/// </summary>
public string DeviceName => deviceName;
public string? DeviceName { get; set; }

/// <summary>
///
/// </summary>
public decimal DeviceMemoryInGB { get; set; }
public decimal DeviceMemoryInGb { get; set; }

/// <summary>
///
Expand All @@ -76,12 +74,12 @@ internal record BrowserSpecs
/// <summary>
///
/// </summary>
public string Locale { get; set; }
public string? Locale { get; set; }

/// <summary>
///
/// </summary>
public string CalculatedOSVersion => calculatedOSVersion;
public string? CalculatedOSVersion => _calculatedOSVersion;

/// <summary>
///
Expand All @@ -91,7 +89,7 @@ internal record BrowserSpecs
/// <summary>
///
/// </summary>
public string Platform { get; set; }
public string? Platform { get; set; }

/// <summary>
///
Expand All @@ -111,12 +109,12 @@ internal record BrowserSpecs
/// <summary>
///
/// </summary>
public BrowserUserAgentData UAHints { get; set; }
public BrowserUserAgentData? UAHints { get; set; }

/// <summary>
///
/// </summary>
public string UserAgent { get; set; }
public string? UserAgent { get; set; }

/// <summary>
///
Expand All @@ -132,10 +130,10 @@ internal record BrowserSpecs
/// </summary>
internal void ParseUserAgent()
{
var result = HttpUserAgentParser.Parse(UserAgent);
calculatedBrowserName = result.Name;
calculatedBrowserVersion = result.Version;
calculatedOSVersion = result.Platform.Value.Name;
var result = HttpUserAgentParser.Parse(UserAgent!);
_calculatedBrowserName = result.Name;
_calculatedBrowserVersion = result.Version;
_calculatedOSVersion = result.Platform?.Name;
Console.WriteLine(result.MobileDeviceType);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Raygun.NetCore.Blazor/Models/BrowserStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ internal record BrowserStats
/// <summary>
///
/// </summary>
public string NetworkEffectiveType { get; set; }
public string? NetworkEffectiveType { get; set; }

/// <summary>
///
Expand Down
20 changes: 10 additions & 10 deletions src/Raygun.NetCore.Blazor/Models/BrowserUserAgentData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,33 @@ internal record BrowserUserAgentData
/// <summary>
/// A string containing the platform architecture. For example, "x86".
/// </summary>
public string Architecture { get; set; }
public string? Architecture { get; set; }

/// <summary>
/// A string containing the architecture bitness. For example, "32" or "64".
/// </summary>
public string Bitness { get; set; }
public string? Bitness { get; set; }

/// <summary>
/// A <see cref="Dictionary{TKey, TValue}"> containing a key representing the brand name a value specifying the publicly reported version of the browser and it's underlying engine.
/// </summary>
/// <remarks>
/// Please note that one object may intentionally contain invalid information to prevent sites from relying on a fixed list of browsers.
/// </remarks>
public Dictionary<string, string> BrandVersions { get; set; }
public Dictionary<string, string>? BrandVersions { get; set; }

/// <summary>
///
/// </summary>
public string CalculatedOSVersion => $"{Platform} {(
public string? CalculatedOSVersion => $"{Platform} {(
Platform == "Windows" && Decimal.Parse(PlatformVersion?.Split(".")?[0] ?? "0") >= 13 ? "11" :
Platform == "Windows" && Decimal.Parse(PlatformVersion?.Split(".")?[0] ?? "0") < 13 ? "10" :
PlatformVersion)}";

/// <summary>
///
/// </summary>
public string CalculatedPlatform
public string? CalculatedPlatform
{
get
{
Expand All @@ -66,12 +66,12 @@ public string CalculatedPlatform
/// <remarks>
/// Please note that one object may intentionally contain invalid information to prevent sites from relying on a fixed list of browsers.
/// </remarks>
public Dictionary<string, string> ComponentVersions { get; set; }
public Dictionary<string, string>? ComponentVersions { get; set; }

/// <summary>
/// A string containing the form-factor of a device. For example, "Tablet" or "VR".
/// </summary>
public string FormFactor { get; set; }
public string? FormFactor { get; set; }

/// <summary>
/// A boolean indicating whether the user agent is running on a mobile device
Expand All @@ -86,17 +86,17 @@ public string CalculatedPlatform
/// <summary>
/// A string containing the model of mobile device. For example, "Pixel 2XL".
/// </summary>
public string Model { get; set; }
public string? Model { get; set; }

/// <summary>
/// A string describing the platform the user agent is running on. For example, "Windows".
/// </summary>
public string Platform { get; set; }
public string? Platform { get; set; }

/// <summary>
/// A string containing the platform version.
/// </summary>
public string PlatformVersion { get; set; }
public string? PlatformVersion { get; set; }

#endregion

Expand Down
10 changes: 5 additions & 5 deletions src/Raygun.NetCore.Blazor/Models/ClientDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ internal record ClientDetails
/// The name of this Client library.
/// </summary>
[JsonInclude]
public string Name { get; set; }
public string? Name { get; set; }

/// <summary>
/// The version of this Client library.
/// </summary>
[JsonInclude]
public string Version { get; set; }
public string? Version { get; set; }

/// <summary>
/// The URL for the repository this Client library is maintained in.
/// </summary>
[JsonInclude]
public string ClientUrl { get; set; }
public string? ClientUrl { get; set; }

#endregion

Expand All @@ -52,7 +52,7 @@ private ClientDetails()
/// <remarks>
/// Sets the Name to "Raygun4Blazor", the Version to the current version of the assembly, and the ClientUrl to the GitHub repository for this project.
/// </remarks>
internal ClientDetails(string name = "Raygun4Blazor")
internal ClientDetails(string? name = "Raygun4Blazor")
{
Name = name;
Version = Assembly.GetExecutingAssembly()
Expand All @@ -67,7 +67,7 @@ internal ClientDetails(string name = "Raygun4Blazor")
/// <param name="name">The name of this Client library.</param>
/// <param name="version">The version of this Client library.</param>
/// <param name="clientUrl">The URL for the repository this Client library is maintained in.</param>
internal ClientDetails(string name, string version, string clientUrl)
internal ClientDetails(string? name, string? version, string? clientUrl)
{
Name = name;
Version = version;
Expand Down
Loading