We welcome code changes that improve this library or fix a problem, please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github. We are very happy to merge your code in the official repository. Make sure to sign our Contributor License Agreement (CLA) first. See our license file for more details.
Most IDEs automatically prompt you to restore the dependencies but if not, use this command:
$ dotnet restoreOr use the Makefile:
$ make restoreBuilding:
$ dotnet buildOr use the Makefile:
$ make buildThe 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.
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).
:bulb Microsoft has a super detailed documentation about .runsettings file.
It needs to look like this:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<EnvironmentVariables>
<STREAM_KEY>api_key_here</STREAM_KEY>
<STREAM_SECRET>secret_key_here</STREAM_SECRET>
</EnvironmentVariables>
</RunConfiguration>
</RunSettings>You can generate this file using the Makefile:
$ make generate_runsettings STREAM_KEY=api_key_here STREAM_SECRET=secret_key_hereIn CLI:
$ dotnet test -s .runsettingsUsing the Makefile:
$ make testTo run specific tests:
$ make test_filtered TEST_FILTER="FullyQualifiedName~StreamChatTests.StreamClientFactoryTests"You can also run tests in Docker using the Makefile:
$ make test_with_dockerTo run specific tests in Docker:
$ make test_filtered_with_docker TEST_FILTER="FullyQualifiedName~StreamChatTests.StreamClientFactoryTests"If you have a mock server running, you can run tests against it by overriding the STREAM_CHAT_URL:
$ make test STREAM_KEY=mock STREAM_SECRET=mock STREAM_CHAT_URL=http://localhost:3030Or in Docker:
$ make test_with_docker STREAM_KEY=mock STREAM_SECRET=mock STREAM_CHAT_URL=http://host.docker.internal:3030Note: When running tests in Docker, we use
host.docker.internal:3030instead oflocalhost:3030because Docker containers cannot access the host machine's localhost directly. The special DNS namehost.docker.internalis automatically resolved to the internal IP address used by the host, allowing the Docker container to communicate with services running on the host machine. This is why we also add the--add-host=host.docker.internal:host-gatewayflag to the Docker run command in the Makefile.
Go to the next section to see how to use it in IDEs.
For VS Code, the recommended extensions are:
- C# by Microsoft
- .NET Core Test Explorer by Jun Huan
Recommended settings (.vscode/settings.json):
{
"omnisharp.testRunSettings": ".runsettings"
}Follow Microsoft's documentation on how to set up .runsettings file.
Follow Jetbrain's documentation on how to set up .runsettings file.