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
6 changes: 6 additions & 0 deletions src/NosCore.Networking/IChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ public interface IChannel
/// </summary>
string Id { get; }

/// <summary>
/// Gets the remote peer's IP address as a string, or null if the
/// underlying session has no routable endpoint yet.
/// </summary>
string? RemoteAddress { get; }

/// <summary>
/// Disconnects the channel asynchronously.
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions src/NosCore.Networking/NetworkChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// -----------------------------------

using System;
using System.Net;
using System.Threading.Tasks;
using SuperSocket.Connection;
using SuperSocket.Server.Abstractions.Session;
Expand Down Expand Up @@ -32,6 +33,12 @@ public NetworkChannel(IAppSession session)
/// </summary>
public string Id => _session.SessionID;

/// <summary>
/// Gets the remote peer's IP address as a string, or null if the
/// underlying session has no routable endpoint yet.
/// </summary>
public string? RemoteAddress => (_session.RemoteEndPoint as IPEndPoint)?.Address.ToString();

/// <summary>
/// Disconnects the channel asynchronously.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/NosCore.Networking/NosCore.Networking.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<RepositoryUrl>https://github.com/NosCoreIO/NosCore.Networking.git</RepositoryUrl>
<PackageIconUrl></PackageIconUrl>
<PackageTags>nostale, noscore, nostale private server source, nostale emulator</PackageTags>
<Version>7.1.0</Version>
<Version>7.2.0</Version>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

In C#/.NET, is adding a new property without a default implementation to a public interface considered a breaking change for existing external implementers?

💡 Result:

Yes, adding a new property without a default implementation to a public interface in C#/.NET is considered a breaking change for existing external implementers. Existing classes implementing the interface will fail to compile because they must provide an implementation for all members, including the new abstract property. This requires recompilation and updates to those classes. Microsoft's official .NET library compatibility guidelines classify "Adding a member to an interface" as requiring judgment, noting potential compile failures without default implementations (DIMs, introduced in C# 8.0/.NET Core 3.0). The .NET SDK's APICompat analyzer explicitly validates and warns against adding members to interfaces (PR #18834), treating it as a breaking change. Runtime guidelines disallow "Adding an abstract method to an interface". Default interface methods (C# 8+) allow non-breaking additions by providing implementations, but without them, it's breaking. Pre-C# 8, interfaces were immutable post-release to avoid breaks.

Citations:


🏁 Script executed:

#!/bin/bash
# Find the IChannel interface definition
find . -type f -name "*.cs" | xargs grep -l "interface IChannel" | head -5

Repository: NosCoreIO/NosCore.Networking

Length of output: 108


🏁 Script executed:

#!/bin/bash
# Search for IChannel and RemoteAddress in the codebase
rg "interface IChannel" -A 20 -B 2

Repository: NosCoreIO/NosCore.Networking

Length of output: 1641


🏁 Script executed:

#!/bin/bash
# Check the csproj file to see current version context
cat -n src/NosCore.Networking/NosCore.Networking.csproj | head -25

Repository: NosCoreIO/NosCore.Networking

Length of output: 1354


🏁 Script executed:

cat -n src/NosCore.Networking/IChannel.cs

Repository: NosCoreIO/NosCore.Networking

Length of output: 1639


🏁 Script executed:

git diff HEAD~1 src/NosCore.Networking/IChannel.cs

Repository: NosCoreIO/NosCore.Networking

Length of output: 260


🏁 Script executed:

git log --oneline -5

Repository: NosCoreIO/NosCore.Networking

Length of output: 137


🏁 Script executed:

git show --stat

Repository: NosCoreIO/NosCore.Networking

Length of output: 4712


🏁 Script executed:

git show src/NosCore.Networking/IChannel.cs

Repository: NosCoreIO/NosCore.Networking

Length of output: 2114


Bump version to 8.0.0 for this breaking interface change.

IChannel is a public interface with a new required property RemoteAddress that lacks a default implementation. All external implementations must be updated to compile. This breaking change requires a major version bump per SemVer; 7.2.0 understates the compatibility impact.

Suggested fix
-		<Version>7.2.0</Version>
+		<Version>8.0.0</Version>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/NosCore.Networking/NosCore.Networking.csproj` at line 15, The package
version in NosCore.Networking.csproj must be bumped to 8.0.0 to reflect the
breaking change: update the <Version> element from 7.2.0 to 8.0.0 and ensure
callers are aware; additionally, update all public implementations of the
IChannel interface to implement the new required RemoteAddress property (or add
a default implementation to IChannel if you intend to avoid a major bump) so
consumers compile; reference the IChannel interface and its RemoteAddress
property when making these code changes.

<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Description>NosCore Networking</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Loading