Skip to content

Commit 0cd9779

Browse files
committed
Allow referencing directly from source
Make types partial, include public visibility in compiled version, provide instructions for source-only linking via dotnet-file. Fixes #1
1 parent eabedfe commit 0cd9779

File tree

5 files changed

+66
-2
lines changed

5 files changed

+66
-2
lines changed

readme.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,34 @@ app.Use(async (context, next) =>
7676
});
7777
```
7878

79+
# Installation
80+
81+
This project can be used either as a regular nuget package:
82+
83+
```
84+
<PackageReference Include="WebSocketChannel" Version="*" />
85+
```
86+
87+
Or alternatively, referenced directly as a source-only dependency using [dotnet-file](https://www.nuget.org/packages/dotnet-file):
88+
89+
```
90+
> dotnet file add https://github.com/devlooped/WebSocketChannel/blob/main/src/WebSocketChannel/WebSocketChannel.cs
91+
> dotnet file add https://github.com/devlooped/WebSocketChannel/blob/main/src/WebSocketChannel/WebSocketExtensions.cs
92+
```
93+
94+
It's also possible to specify a desired target location for the referenced source files, such as:
95+
96+
```
97+
> dotnet file add https://github.com/devlooped/WebSocketChannel/blob/main/src/WebSocketChannel/WebSocketChannel.cs src/MyProject/External/.
98+
> dotnet file add https://github.com/devlooped/WebSocketChannel/blob/main/src/WebSocketChannel/WebSocketExtensions.cs src/MyProject/External/.
99+
```
100+
101+
When referenced as loose source files, it's easy to also get automated PRs when the upstream files change,
102+
as in the [dotnet-file.yml](https://github.com/devlooped/dotnet-file/blob/main/.github/workflows/dotnet-file.yml) workflow that
103+
keeps the repository up to date with a template. See also [dotnet-config](https://dotnetconfig.org), which is used to
104+
for the `dotnet-file` configuration settings that tracks all this.
105+
106+
79107

80108
# Dogfooding
81109

src/WebSocketChannel/Visibility.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Devlooped.Net
2+
{
3+
public static partial class WebSocketChannel { }
4+
}
5+
6+
namespace System.Net.WebSockets
7+
{
8+
public static partial class WebSocketExtensions { }
9+
}

src/WebSocketChannel/WebSocketChannel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Devlooped.Net;
1010
/// Due to the nature of the underlying <see cref="WebSocket"/>, no concurrent writing
1111
/// or reading is allowed, so the returned channel is effectively thread-safe by design.
1212
/// </remarks>
13-
public static class WebSocketChannel
13+
static partial class WebSocketChannel
1414
{
1515
/// <summary>
1616
/// Creates a channel over the given <paramref name="webSocket"/> for reading/writing

src/WebSocketChannel/WebSocketExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace System.Net.WebSockets;
99
/// API.
1010
/// </summary>
1111
[EditorBrowsable(EditorBrowsableState.Never)]
12-
public static class WebSocketExtensions
12+
static partial class WebSocketExtensions
1313
{
1414
/// <summary>
1515
/// Creates a channel over the given <paramref name="webSocket"/> for reading/writing

src/WebSocketChannel/readme.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,33 @@ app.Use(async (context, next) =>
7272
```
7373

7474

75+
# Installation
76+
77+
This project can be used either as a regular nuget package:
78+
79+
```
80+
<PackageReference Include="WebSocketChannel" Version="*" />
81+
```
82+
83+
Or alternatively, referenced directly as a source-only dependency using [dotnet-file](https://www.nuget.org/packages/dotnet-file):
84+
85+
```
86+
> dotnet file add https://github.com/devlooped/WebSocketChannel/blob/main/src/WebSocketChannel/WebSocketChannel.cs
87+
> dotnet file add https://github.com/devlooped/WebSocketChannel/blob/main/src/WebSocketChannel/WebSocketExtensions.cs
88+
```
89+
90+
It's also possible to specify a desired target location for the referenced source files, such as:
91+
92+
```
93+
> dotnet file add https://github.com/devlooped/WebSocketChannel/blob/main/src/WebSocketChannel/WebSocketChannel.cs src/MyProject/External/.
94+
> dotnet file add https://github.com/devlooped/WebSocketChannel/blob/main/src/WebSocketChannel/WebSocketExtensions.cs src/MyProject/External/.
95+
```
96+
97+
When referenced as loose source files, it's easy to also get automated PRs when the upstream files change,
98+
as in the [dotnet-file.yml](https://github.com/devlooped/dotnet-file/blob/main/.github/workflows/dotnet-file.yml) workflow that
99+
keeps the repository up to date with a template. See also [dotnet-config](https://dotnetconfig.org), which is used to
100+
for the `dotnet-file` configuration settings that tracks all this.
101+
75102

76103

77104
## Sponsors

0 commit comments

Comments
 (0)