Skip to content

Commit

Permalink
fix: #9 Fix warnings (#12)
Browse files Browse the repository at this point in the history
* add ApiKey to appsettings.json in tests

* apply naming suggestions by Rider IDE

* inject mocked IJSRuntime

* HttpMethod should be String not type HttpMethod

* wip fixing tests

* simple fix

* fix tests

* cleanup

* cleanup

* test cleanup

* more cleanup

* restore file

* ci: dotnet formatting

* simplify job

* test break formatting

* fix format

* dotnet format

* fixing warnings

* fix warnings

* 5 warnings

* ci: Code formatting (#7)

* ci: dotnet formatting

* simplify job

* test break formatting

* fix format

* dotnet format

* fix acronym formatting

* dotnet format

* revert removing underscores
miquelbeltran authored Jul 24, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent f8d837f commit 08258d4
Showing 28 changed files with 192 additions and 187 deletions.
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
{
/// <summary>
///
/// </summary>
public class Class1
{

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
{
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
using KristofferStrube.Blazor.Window;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Raygun.NetCore.Blazor;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting
{
Original file line number Diff line number Diff line change
@@ -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(Raygun_Blazor_EnhancedStackTraceExtensions).Assembly.FullName);
}

}
8 changes: 5 additions & 3 deletions src/Raygun.NetCore.Blazor/Extensions/StackFrameExtensions.cs
Original file line number Diff line number Diff line change
@@ -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);
}
14 changes: 7 additions & 7 deletions src/Raygun.NetCore.Blazor/Models/BreadcrumbDetails.cs
Original file line number Diff line number Diff line change
@@ -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.
@@ -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.
@@ -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;
40 changes: 19 additions & 21 deletions src/Raygun.NetCore.Blazor/Models/BrowserSpecs.cs
Original file line number Diff line number Diff line change
@@ -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;

#endregion

@@ -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>
///
@@ -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>
///
@@ -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>
///
@@ -91,7 +89,7 @@ internal record BrowserSpecs
/// <summary>
///
/// </summary>
public string Platform { get; set; }
public string? Platform { get; set; }

/// <summary>
///
@@ -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>
///
@@ -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);
}

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

/// <summary>
///
20 changes: 10 additions & 10 deletions src/Raygun.NetCore.Blazor/Models/BrowserUserAgentData.cs
Original file line number Diff line number Diff line change
@@ -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
{
@@ -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
@@ -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

10 changes: 5 additions & 5 deletions src/Raygun.NetCore.Blazor/Models/ClientDetails.cs
Original file line number Diff line number Diff line change
@@ -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

@@ -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()
@@ -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;
Loading

0 comments on commit 08258d4

Please sign in to comment.