Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing signatures #51

Merged
merged 18 commits into from
Apr 8, 2020
Merged

Fix missing signatures #51

merged 18 commits into from
Apr 8, 2020

Conversation

scottinet
Copy link
Contributor

@scottinet scottinet commented Apr 1, 2020

Description

The WebSocket class was abstracting the System.net.WebSockets.ClientWebSocket object by storing it in a dynamic variable.
This was made to allow mocking the ClientWebSocket class (which is final and thus cannot be extended) via duck typing, using a custom IClientWebSocket interface which reproduces parts of the ClientWebSocket API.

Problem is: it seems that the Visual Studio C# linker is smart enough to remove unused functions from compiled applications, but it's unable to detect functions used through dynamic variables.
This made ClientWebSocket functions stripped from applications using our SDK, making it useless with that protocol.

This PR fixes this situation by making our WebSocket protocol implementation use only objects implementing our IClientWebSocket interface, completely removing duck typing.
I added a humble object creating and wrapping ClientWebSocket instances to make that class compatible with our custom interface. That humble object explicitly uses ClientWebSocket functions, forcing the C# linker to keep them in the compiled product.

Mocking is made by injecting a custom mock objecting implementing that interface.

Other changes

  • Fix all warnings (99% of them being missing XML documentation)

How to review

The actual fix is in the Kuzzle/Protocol/WebSocket.cs file (and its unit test counterpart). All other changes are about fixing warnings.

@codecov
Copy link

codecov bot commented Apr 1, 2020

Codecov Report

Merging #51 into 2-dev will decrease coverage by 0.89%.
The diff coverage is 45.28%.

Impacted file tree graph

@@            Coverage Diff             @@
##            2-dev      #51      +/-   ##
==========================================
- Coverage   83.09%   82.19%   -0.90%     
==========================================
  Files          34       34              
  Lines        1644     1674      +30     
  Branches      196      194       -2     
==========================================
+ Hits         1366     1376      +10     
- Misses        255      275      +20     
  Partials       23       23              
Impacted Files Coverage Δ
Kuzzle/API/Controllers/AdminController.cs 100.00% <ø> (ø)
Kuzzle/API/Controllers/RealtimeController.cs 88.14% <0.00%> (-4.10%) ⬇️
Kuzzle/EventHandler/Events/SubscriptionEvent.cs 100.00% <ø> (ø)
...vents/SubscriptionEvents/SubscriptionClearEvent.cs 100.00% <ø> (ø)
Kuzzle/EventHandler/KuzzleEventHandler.cs 74.11% <ø> (ø)
Kuzzle/Exceptions/UnauthorizeException.cs 100.00% <ø> (ø)
Kuzzle/Kuzzle.cs 83.75% <ø> (ø)
Kuzzle/Offline/OfflineManager.cs 70.73% <ø> (ø)
Kuzzle/Offline/Query/QueryReplayer.cs 77.86% <ø> (ø)
Kuzzle/Offline/Query/TimedQuery.cs 29.41% <0.00%> (-0.90%) ⬇️
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aec1d5b...e695dc1. Read the comment docs.

@Aschen Aschen merged commit 4ce156a into 2-dev Apr 8, 2020
@Aschen Aschen deleted the fix-missing-signatures branch April 8, 2020 03:09
@scottinet scottinet mentioned this pull request Apr 9, 2020
scottinet added a commit that referenced this pull request Apr 9, 2020
# [2.0.2](https://github.com/kuzzleio/sdk-csharp/releases/tag/2.0.2) (2020-04-09)

#### Bug fixes

- [ [#51](#51) ] Fix missing signatures   ([scottinet](https://github.com/scottinet))
---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants