Skip to content

Commit 1810ea2

Browse files
authored
feat: major refactor with breaking changes (#92)
BREAKING CHANGE: The library received many changes in v1.0 to make it easier to use and more maintanable in the future. The main change is that both [`Channel`](https://github.com/GetStream/stream-chat-net/blob/0.26.0/src/stream-chat-net/Channel.cs) and [`Client`](https://github.com/GetStream/stream-chat-net/blob/0.26.0/src/stream-chat-net/Client.cs) classes have been separated into small modules that we call clients. (This resambles the [structure of our Java library](https://github.com/GetStream/stream-chat-java/tree/1.5.0/src/main/java/io/getstream/chat/java/services) as well.) Main changes: - `Channel` and `Client` classes are gone, and have been organized into smaller clients in `StreamChat.Clients` namespace. - These clients do not maintain state as `Channel` used to did earlier where [it kept the `channelType` and `channelId` in the memory](https://github.com/GetStream/stream-chat-net/blob/0.26.0/src/stream-chat-net/Channel.cs#L34-#L35). So this means that you'll need to pass in `channelType` and `channelId` to a lot of method calls in `IChannelClient`. - Async method names have `Async` suffix now. - All public methods and classes have documentation. - Identifiers has been renamed from `ID` to `Id` to follow [Microsoft's naming guide](https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/capitalization-conventions). Such as `userID` -> `userId`. - A lot of data classes have been renamed to make more sense. Such as `ChannelObject` -> `Channel`. - Data classes have been moved to `StreamChat.Models` namespace. - Changed all `DateTime` -> `DateTimeOffset` as it's more suitable for us. - Full feature parity: all backend APIs are available. - Returned values are type of `ApiResponse` and expose rate limit informaiton with `GetRateLimit()` method. - The folder structure of the project has been reorganized to follow [Microsoft's recommendation](https://gist.github.com/davidfowl/ed7564297c61fe9ab814). - Unit tests have been improved. They are smaller, more focused and have cleanup methods. - Added .NET 6.0 to the target frameworks.
1 parent f3100f5 commit 1810ea2

File tree

162 files changed

+7690
-6339
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+7690
-6339
lines changed

.github/workflows/ci.yaml

+8-14
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,35 @@ concurrency:
88

99
jobs:
1010
basic:
11-
name: Run tests on ${{ matrix.os }}
12-
runs-on: ${{ matrix.os }}
11+
name: 🧪 Run tests
12+
runs-on: ubuntu-latest
1313
env:
1414
DOTNET_CLI_TELEMETRY_OPTOUT: "true"
15-
strategy:
16-
max-parallel: 1
17-
matrix:
18-
os: [macos-latest, ubuntu-latest, windows-latest]
19-
fail-fast: false
2015
steps:
2116
- uses: actions/checkout@v2
2217
with:
2318
fetch-depth: 0
2419

2520
- uses: wagoid/commitlint-github-action@v4
26-
if: ${{ matrix.os == 'ubuntu-latest' }}
2721

2822
- name: Setup dotnet
2923
uses: actions/setup-dotnet@v1
3024
with:
31-
dotnet-version: 5.0.x
25+
dotnet-version: 6.0.x
3226

3327
- name: Dependency cache
3428
uses: actions/cache@v2
3529
id: cache
3630
with:
3731
path: ~/.nuget/packages
38-
key: ${{ runner.os }}-nuget-${{ hashFiles('src/**/*.csproj') }}
32+
key: ${{ runner.os }}-nuget-${{ hashFiles('./**/*.csproj') }}
3933

4034
- name: Install dependencies
4135
if: steps.cache.outputs.cache-hit != 'true'
42-
run: dotnet restore ./src
36+
run: dotnet restore
4337

4438
- name: Run tests
45-
run: dotnet test ./src/stream-chat-net-test
39+
run: dotnet test
4640
env:
47-
STREAM_API_SECRET: ${{ secrets.STREAM_API_SECRET }}
48-
STREAM_API_KEY: ${{ secrets.STREAM_API_KEY }}
41+
STREAM_SECRET: ${{ secrets.STREAM_API_SECRET }}
42+
STREAM_KEY: ${{ secrets.STREAM_API_KEY }}

.github/workflows/initiate_release.yml

+10-1
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,23 @@ on:
99

1010
jobs:
1111
init_release:
12+
name: 🚀 Create release PR
1213
runs-on: ubuntu-latest
1314
steps:
1415
- uses: actions/checkout@v2
1516
with:
1617
fetch-depth: 0 # gives the changelog generator access to all previous commits
1718

1819
- name: Create release branch
19-
run: scripts/create_release_branch.sh "${{ github.event.inputs.version }}"
20+
env:
21+
VERSION: ${{ github.event.inputs.version }}
22+
run: |
23+
npx --yes standard-version@9.3.2 --release-as "$VERSION" --skip.tag --skip.commit --tag-prefix=
24+
git config --global user.name 'github-actions'
25+
git config --global user.email 'release@getstream.io'
26+
git checkout -q -b "release-$VERSION"
27+
git commit -am "chore(release): $VERSION"
28+
git push -q -u origin "release-$VERSION"
2029
2130
- name: Get changelog diff
2231
uses: actions/github-script@v5

.github/workflows/release.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88

99
jobs:
1010
Release:
11+
name: 🚀 Release
1112
if: github.event.pull_request.merged && startsWith(github.head_ref, 'release-')
1213
runs-on: ubuntu-latest
1314
env:
@@ -31,13 +32,13 @@ jobs:
3132
- name: Setup dotnet
3233
uses: actions/setup-dotnet@v1
3334
with:
34-
dotnet-version: "5.0.x"
35+
dotnet-version: "6.0.x"
3536

3637
- name: Create the package
3738
run: dotnet pack --configuration Release ./src
3839

3940
- name: Publish the package
40-
run: dotnet nuget push "./src/stream-chat-net/bin/Release/*.nupkg" -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
41+
run: dotnet nuget push "./src/bin/Release/*.nupkg" -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
4142

4243
- name: Create release on GitHub
4344
uses: ncipollo/release-action@v1

.github/workflows/reviewdog.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: reviewdog
1+
name: Reviewdog
22
on:
33
pull_request:
44

@@ -8,22 +8,21 @@ concurrency:
88

99
jobs:
1010
reviewdog:
11+
name: 🐶 Reviewdog
1112
runs-on: ubuntu-latest
1213
steps:
1314
- uses: actions/checkout@v2
1415

1516
- uses: reviewdog/action-setup@v1
16-
with:
17-
reviewdog_version: latest
1817

1918
- name: Setup dotnet
2019
uses: actions/setup-dotnet@v1
2120
with:
22-
dotnet-version: 5.0.x
21+
dotnet-version: 6.0.x
2322

2423
- name: Reviewdog
2524
env:
2625
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2726
run: |
28-
dotnet build -clp:NoSummary -p:GenerateFullPaths=true --no-incremental --nologo -f net5.0 -v q src \
27+
dotnet build -clp:NoSummary -p:GenerateFullPaths=true --no-incremental --nologo -f net6.0 -v q \
2928
| reviewdog -f=dotnet -name=dotnet -reporter=github-pr-review

.stylecop.ruleset

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RuleSet Name="Rules for stream-chat-net" Description="Code analysis rules for stream-chat-net.csproj." ToolsVersion="14.0">
3+
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.SpecialRules">
4+
<Rule Id="SA0001" Action="None" /> <!-- XML comment analysis is disabled due to project configuration -->
5+
</Rules>
6+
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.ReadabilityRules">
7+
<Rule Id="SA1101" Action="None" /> <!-- Prefix local calls with this -->
8+
<Rule Id="SA1116" Action="None" /> <!-- The parameters should begin on the line after the declaration -->
9+
<Rule Id="SA1117" Action="None" /> <!-- The parameters should all be placed on the same line -->
10+
<Rule Id="SA1127" Action="None" /> <!-- Generic type constraints should be on their own line -->
11+
<Rule Id="SA1128" Action="None" /> <!-- Put constructor initializers on their own line -->
12+
</Rules>
13+
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.OrderingRules">
14+
<Rule Id="SA1200" Action="None" /> <!-- Using directive should appear within a namespace declaration -->
15+
<Rule Id="SA1201" Action="None" /> <!-- A enum should not follow a class -->
16+
<Rule Id="SA1202" Action="None" /> <!-- 'public' members should come before 'internal' members -->
17+
<Rule Id="SA1204" Action="None" /> <!-- Static members should appear before non-static members -->
18+
</Rules>
19+
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.NamingRules">
20+
<Rule Id="SA1309" Action="None" /> <!-- Should not begin with an underscore -->
21+
</Rules>
22+
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.MaintainabilityRules">
23+
<Rule Id="SA1402" Action="None" /> <!-- File may only contain a single type -->
24+
</Rules>
25+
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.LayoutRules">
26+
<Rule Id="SA1503" Action="None" /> <!-- Braces should not be omitted -->
27+
<Rule Id="SA1516" Action="None" /> <!-- Elements should be separated by blank line -->
28+
<Rule Id="CS1591" Action="None" /> <!-- Missing XML comment for publicly visible type or member -->
29+
</Rules>
30+
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.DocumentationRules">
31+
<Rule Id="SA1600" Action="None" /> <!-- Elements should be documented -->
32+
<Rule Id="SA1601" Action="None" /> <!-- Partial elements should be documented -->
33+
<Rule Id="SA1602" Action="None" /> <!-- Enumeration items should be documented -->
34+
<Rule Id="SA1611" Action="None" /> <!-- FThe documentation for parameter is missing -->
35+
<Rule Id="SA1615" Action="None" /> <!-- Element return value should be documented -->
36+
<Rule Id="SA1618" Action="None" /> <!-- TThe documentation for type parameter is missing -->
37+
<Rule Id="SA1623" Action="None" /> <!-- The property's documentation summary text should begin with: 'Gets or sets' -->
38+
<Rule Id="SA1629" Action="None" /> <!-- Documentation text should end with a period -->
39+
<Rule Id="SA1633" Action="None" /> <!-- The file header is missing or not located at the top of the file -->
40+
<Rule Id="SA1649" Action="None" /> <!-- File name should match first type name -->
41+
</Rules>
42+
</RuleSet>

.versionrc.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const csprojUpdater = {
2+
VERSION_REGEX: /<Version>(.+)<\/Version>/,
3+
4+
readVersion: function (contents) {
5+
const version = this.VERSION_REGEX.exec(contents)[1];
6+
return version;
7+
},
8+
9+
writeVersion: function (contents, version) {
10+
return contents.replace(this.VERSION_REGEX.exec(contents)[0], `<Version>${version}</Version>`);
11+
}
12+
}
13+
14+
module.exports = {
15+
bumpFiles: [{ filename: './src/stream-chat-net.csproj', updater: csprojUpdater }],
16+
}

CONTRIBUTING.md

+7-8
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ We welcome code changes that improve this library or fix a problem, please make
99
Most IDEs automatically prompt you to restore the dependencies but if not, use this command:
1010

1111
```shell
12-
$ dotnet restore ./src
12+
$ dotnet restore
1313
```
1414

1515
Building:
1616

1717
```shell
18-
$ dotnet build ./src
18+
$ dotnet build
1919
```
2020

2121
### Run tests
2222

23-
The tests we have are full fledged integration tests, meaning they will actually reach out to a Stream app. Hence the tests require at least two environment variables: `STREAM_API_KEY` and `STREAM_API_SECRET`.
23+
The tests we have are full fledged integration tests, meaning they will actually reach out to a Stream app. Hence the tests require at least two environment variables: `STREAM_KEY` and `STREAM_SECRET`.
2424

2525
To have these env vars available for the test running, you need to set up a `.runsettings` file in the root of the project (don't worry, it's gitignored).
2626

@@ -33,16 +33,16 @@ It needs to look like this:
3333
<RunSettings>
3434
<RunConfiguration>
3535
<EnvironmentVariables>
36-
<STREAM_API_KEY>api_key_here</STREAM_API_KEY>
37-
<STREAM_API_SECRET>secret_key_here</STREAM_API_SECRET>
36+
<STREAM_KEY>api_key_here</STREAM_KEY>
37+
<STREAM_SECRET>secret_key_here</STREAM_SECRET>
3838
</EnvironmentVariables>
3939
</RunConfiguration>
4040
</RunSettings>
4141
```
4242

4343
In CLI:
4444
```shell
45-
$ dotnet test -s .runsettings ./src/stream-chat-net-test
45+
$ dotnet test -s .runsettings
4646
```
4747

4848
Go to the next section to see how to use it in IDEs.
@@ -58,8 +58,7 @@ For VS Code, the recommended extensions are:
5858
Recommended settings (`.vscode/settings.json`):
5959
```json
6060
{
61-
"omnisharp.testRunSettings": ".runsettings",
62-
"dotnet-test-explorer.testProjectPath": "./src/stream-chat-net-test",
61+
"omnisharp.testRunSettings": ".runsettings"
6362
}
6463
```
6564

0 commit comments

Comments
 (0)