Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,18 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>9.0.4</Version>
<Version>9.0.5</Version>
</PropertyGroup>

<PropertyGroup>
<PackageTags>BootstrapBlazor Socket</PackageTags>
<Description>BootstrapBlazor extensions of Socket</Description>
</PropertyGroup>

<PropertyGroup>
<NET8Version>8.0.*</NET8Version>
<NET9Version>9.0.*</NET9Version>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(NET8Version)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(NET8Version)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(NET9Version)" />
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

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

The .NET 8.0 target framework is incorrectly using NET9Version. Line 26 should use $(NET8Version) to match the pattern established for other .NET 8.0 dependencies.

Suggested change
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(NET9Version)" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(NET8Version)" />

Copilot uses AI. Check for mistakes.
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(NET9Version)" />
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

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

The .NET 8.0 target framework is incorrectly using NET9Version. Line 26 should use $(NET8Version) to match the pattern established for other .NET 8.0 dependencies.

Copilot uses AI. Check for mistakes.
</ItemGroup>

<ItemGroup>
</ItemGroup>
Comment on lines +33 to +34
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

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

Empty ItemGroup should be removed as it serves no purpose and clutters the project file.

Suggested change
<ItemGroup>
</ItemGroup>

Copilot uses AI. Check for mistakes.

<ItemGroup>
<Using Include="BootstrapBlazor.DataAdapters" />
<Using Include="BootstrapBlazor.DataHandlers" />
<Using Include="BootstrapBlazor.DataConverters" />
<Using Include="BootstrapBlazor.Socket.DataAdapters" />
<Using Include="BootstrapBlazor.Socket.DataHandlers" />
<Using Include="BootstrapBlazor.Socket.DataConverters" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

namespace BootstrapBlazor.DataAdapters;
namespace BootstrapBlazor.Socket.DataAdapters;

/// <summary>
/// Provides a base implementation for adapting data packages between different systems or formats.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

namespace BootstrapBlazor.DataAdapters;
namespace BootstrapBlazor.Socket.DataAdapters;

/// <summary>
/// Defines an adapter for handling and transmitting data packages to a target destination.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System.Text;

namespace BootstrapBlazor.Components.DataConverter;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue: Namespace change introduces inconsistency with other files.

Please update the namespace to 'BootstrapBlazor.Socket.DataConverters' for consistency with the rest of the codebase and to prevent potential type resolution issues.

namespace BootstrapBlazorSocket.DataConverter;
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

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

The namespace has a typo - missing dot between 'BootstrapBlazor' and 'Socket'. Should be 'BootstrapBlazor.Socket.DataConverter' to match the pattern used in other files.

Suggested change
namespace BootstrapBlazorSocket.DataConverter;
namespace BootstrapBlazor.Socket.DataConverter;

Copilot uses AI. Check for mistakes.

/// <summary>
/// 二进制 与 Byte 数组转换方法
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

using BootstrapBlazor.Socket.Logging;
using System.Reflection;

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// Provides a base class for converting socket data into a specified entity type.
Expand Down Expand Up @@ -38,7 +39,10 @@ public virtual bool TryConvertTo(ReadOnlyMemory<byte> data, [NotNullWhen(true)]
ret = true;
}
}
catch { }
catch (Exception ex)
{
SocketLogging.LogError(ex, "DataConverter TryConvertTo failed");
}

return ret;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Linq.Expressions;
using System.Reflection;

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// 数据转换器集合类
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// Represents an attribute used to mark a field as a socket data field.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

namespace BootstrapBlazor.Components.DataConverter;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Namespace 'BootstrapBlazor.Socket.DataConverter' is singular, while others use plural.

Consider renaming the namespace to 'BootstrapBlazor.Socket.DataConverters' to match the convention used elsewhere in the codebase.

Suggested change
namespace BootstrapBlazor.Components.DataConverter;
namespace BootstrapBlazor.Socket.DataConverters;

namespace BootstrapBlazor.Socket.DataConverter;

/// <summary>
/// 十六进制 与 Byte 数组转换方法
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// Socket 数据转换器接口
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

namespace BootstrapBlazor.DataHandlers;
namespace BootstrapBlazor.Socket.DataHandlers;

/// <summary>
/// Provides a base implementation for handling data packages in a communication system.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Buffers;
using System.Text;

namespace BootstrapBlazor.DataHandlers;
namespace BootstrapBlazor.Socket.DataHandlers;

/// <summary>
/// Handles data packages that are delimited by a specific sequence of bytes or characters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

namespace BootstrapBlazor.DataHandlers;
namespace BootstrapBlazor.Socket.DataHandlers;

/// <summary>
/// Handles fixed-length data packages by processing incoming data of a specified length.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

namespace BootstrapBlazor.DataHandlers;
namespace BootstrapBlazor.Socket.DataHandlers;

/// <summary>
/// Defines an interface for adapting data packages to and from a TCP socket connection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

static class DataPropertyExtensions
{
Expand Down
44 changes: 44 additions & 0 deletions src/extensions/BootstrapBlazor.Socket/Logging/SocketLogging.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

using Microsoft.Extensions.Logging;

namespace BootstrapBlazor.Socket.Logging;

/// <summary>
/// Socket 日志记录类
/// </summary>
public static class SocketLogging
{
private static ILogger? _logger;
private static bool _inited;

/// <summary>
/// 返回 是否已经初始化
/// </summary>
public static bool Inited => _inited;

/// <summary>
/// 初始化 ILogger 实例
/// </summary>
/// <param name="logger"></param>
public static void Init(ILogger logger)
{
_inited = true;
_logger = logger;
}

/// <summary>
///
/// </summary>
/// <param name="message"></param>
Comment on lines +33 to +35
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

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

Empty XML documentation comment should be completed to describe the LogError method's purpose and parameters.

Suggested change
///
/// </summary>
/// <param name="message"></param>
/// Logs an error message using the configured logger.
/// </summary>
/// <param name="message">The error message to log.</param>

Copilot uses AI. Check for mistakes.
public static void LogError(string message) => _logger?.LogError(message);

/// <summary>
///
/// </summary>
/// <param name="ex"></param>
/// <param name="message"></param>
Comment on lines +33 to +42
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

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

Empty XML documentation comment should be completed to describe the LogError overload method's purpose and parameters.

Suggested change
///
/// </summary>
/// <param name="message"></param>
public static void LogError(string message) => _logger?.LogError(message);
/// <summary>
///
/// </summary>
/// <param name="ex"></param>
/// <param name="message"></param>
/// Logs an error message using the configured logger.
/// </summary>
/// <param name="message">The error message to log.</param>
public static void LogError(string message) => _logger?.LogError(message);
/// <summary>
/// Logs an exception and an optional error message using the configured logger.
/// </summary>
/// <param name="ex">The exception to log.</param>
/// <param name="message">An optional error message to log with the exception.</param>

Copilot uses AI. Check for mistakes.
public static void LogError(Exception ex, string? message) => _logger?.LogError(ex, message);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// Sokcet 数据转换为 bool 数据转换器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// Sokcet 数据转换为 byte[] 数组转换器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System.Buffers.Binary;

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// Sokcet 数据转换为 double 数据大端转换器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System.Buffers.Binary;

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// Sokcet 数据转换为 double 数据小端转换器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// Sokcet 数据转换为 Enum 数据转换器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System.Buffers.Binary;

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// Sokcet 数据转换为 short 数据大端转换器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System.Buffers.Binary;

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// Sokcet 数据转换为 short 数据小端转换器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System.Buffers.Binary;

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// Sokcet 数据转换为 int 数据大端转换器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System.Buffers.Binary;

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// Sokcet 数据转换为 int 数据小端转换器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System.Buffers.Binary;

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// Sokcet 数据转换为 long 数据大端转换器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System.Buffers.Binary;

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// Sokcet 数据转换为 long 数据小端转换器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System.Buffers.Binary;

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// Sokcet 数据转换为 float 数据大端转换器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System.Buffers.Binary;

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// Sokcet 数据转换为 float 数据小端转换器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System.Text;

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// Sokcet 数据转换为 string 数据转换器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System.Buffers.Binary;

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// Sokcet 数据转换为 ushort 数据大端转换器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System.Buffers.Binary;

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// Sokcet 数据转换为 ushort 数据小端转换器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System.Buffers.Binary;

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// Sokcet 数据转换为 uint 数据大端转换器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System.Buffers.Binary;

namespace BootstrapBlazor.DataConverters;
namespace BootstrapBlazor.Socket.DataConverters;

/// <summary>
/// Sokcet 数据转换为 uint 数据小端转换器
Expand Down
Loading