1
0
mirror of https://github.com/chylex/.NET-Community-Toolkit.git synced 2024-11-23 04:42:45 +01:00
Commit Graph

1968 Commits

Author SHA1 Message Date
Sergio Pedri
a381191e35 Added notification to AsyncRelayCommand.CanBeCanceled 2020-10-07 01:07:11 +02:00
Sergio Pedri
de1c6e1e82 Added new ObservableObject.OnProperty... overloads 2020-10-07 00:55:34 +02:00
hansmbakker
94794bff3a Mutable and subclassable version of ObservableGroup 2020-10-06 22:32:30 +02:00
Sergio Pedri
31c995264b Code refactoring to remove duplicate API 2020-10-06 19:12:52 +02:00
Sergio Pedri
bc33155b33 Merge branch 'master' into bugfix/pool-writer-allocations 2020-10-06 19:06:36 +02:00
Michael Hawker MSFT (XAML Llama)
25be5c2cb4 Merge pull request #3380 from Sergio0694/feature/string-pool
StringPool class (ArrayPool<T>-like to cache strings)
2020-10-06 09:52:02 -07:00
Michael Hawker MSFT (XAML Llama)
2444c48e0a Merge branch 'master' into feature/string-pool 2020-10-06 09:51:52 -07:00
Michael Hawker MSFT (XAML Llama)
843c366afa Merge pull request #3505 from Sergio0694/tweak/mvvm-docs
Leftover ObservableObject XML docs fix, minor tweaks
2020-10-06 09:51:15 -07:00
Michael Hawker MSFT (XAML Llama)
3326e8df82 Merge branch 'master' into tweak/mvvm-docs 2020-10-06 09:51:04 -07:00
Michael Hawker MSFT (XAML Llama)
1e4310ab0b Merge pull request #3513 from Sergio0694/refactoring/bounds-checks
Removed unsafe indexing from StrongReferenceMessenger
2020-10-06 09:49:51 -07:00
Michael Hawker MSFT (XAML Llama)
052bc08a3e Merge branch 'master' into feature/string-pool 2020-10-06 09:03:38 -07:00
Sergio Pedri
0c3eee6ce8 Merge branch 'master' into feature/memory-cast 2020-10-06 17:16:37 +02:00
Sergio Pedri
a14c69e699 Merge branch 'master' into refactoring/bounds-checks 2020-10-06 16:39:16 +02:00
Sergio Pedri
6dce7301bc Merge branch 'master' into feature/ibuffer-writer-stream2 2020-10-06 16:35:04 +02:00
msftbot[bot]
f2969ebb29 Performance improvement in MemoryStream (#3477)
## PR type:
What kind of change does this PR introduce?
<!-- Please uncomment one or more that apply to this PR. -->

- Performance improvement
<!-- - Bugfix -->
<!-- - Feature -->
<!-- - Code style update (formatting) -->
<!-- - Refactoring (no functional changes, no api changes) -->
<!-- - Build or CI related changes -->
<!-- - Documentation content changes -->
<!-- - Sample app changes -->
<!-- - Other... Please describe: -->


## What is the current behavior?
<!-- Please describe the current behavior that you are modifying, or link to a relevant issue. -->
The `MemoryStream` type wraps a `Memory<byte>` instance, so every time a read/write operation needs to be performed, it will need to use `Memory<T>.Span`, which is relatively expensive to invoke, as it needs to handle multiple possible sources of data. We can use generic types and the value delegate trick (constrained generic struct + interface) to optimize this away.

## What is the new behavior?
<!-- Describe how was this issue resolved or changed? -->
We now use a `MemoryStream<TSource>` type (which is internal anyway) and have a bunch of `IMemorySource` types specifically supporting `byte[]` and `MemoryManager<byte>` sources with additional optimizations wherever possible. Also, just using this already removes all the overhead of dynamically creating a `Span<T>` from the wrapped `Memory<T>` instance.

Here's a benchmark I put together to show the before/after:

![image](https://user-images.githubusercontent.com/10199417/93274471-be7c0d00-f7ba-11ea-9672-0a24b08908cf.png)

The benchmark consists of writing 1024 times a 1024 bytes buffer to a target `Stream` instance.
The new `MemoryStream<TSource>` version is almost 25% faster just thanks to this change 🚀

## PR Checklist

Please check if your PR fulfills the following requirements:

- [X] Tested code with current [supported SDKs](../readme.md#supported)
- [ ] ~~Pull Request has been submitted to the documentation repository [instructions](..\contributing.md#docs).~~
- [ ] ~~Sample in sample app has been added / updated (for bug fixes / features)~~
    - [ ] ~~Icon has been created (if new sample) following the [Thumbnail Style Guide and templates](https://github.com/windows-toolkit/WindowsCommunityToolkit-design-assets)~~
- [X] Tests for the changes have been added (for bug fixes / features) (if applicable)
- [X] Header has been added to all new source files (run *build/UpdateHeaders.bat*)
- [X] Contains **NO** breaking changes
2020-10-06 14:33:35 +00:00
Sergio Pedri
5ab9968933 Suppressed GC finalize in MemoryOwner<T>.Slice 2020-10-06 16:03:40 +02:00
Michael Hawker MSFT (XAML Llama)
b586d50da2 Merge branch 'master' into tweak/mvvm-docs 2020-10-06 06:59:53 -07:00
Michael Hawker MSFT (XAML Llama)
e77edb3e42 Merge branch 'master' into refactoring/bounds-checks 2020-10-06 06:58:28 -07:00
Michael Hawker MSFT (XAML Llama)
08f7536c7b Merge branch 'master' into performance/generic-memory-stream 2020-10-06 06:55:55 -07:00
Sergio Pedri
29949bf642 Minor code tweaks 2020-10-06 15:16:39 +02:00
Sergio Pedri
368111012d Removed callvirt-s in BufferWriterStream and AsStream cast 2020-10-06 13:41:57 +02:00
msftbot[bot]
188b906ee7 Shameful rename of [IsNullOr]WhiteSpace Guard APIs (#3515)
## Overview
Some `Guard` APIs were incorrectly using the wrong capitalization for the `WhiteSpace` part, not following the same structure of the actual APIs in the BCL (eg. `string.IsNullOrWhiteSpace`). This PR deprecates them and adds new APIs with the right name.

...I'm sorry 😅

<!-- Add a brief overview here of the feature/bug & fix. -->

## PR Type
What kind of change does this PR introduce?
<!-- Please uncomment one or more that apply to this PR. -->

- API rename
- API deprecation

## PR Checklist

Please check if your PR fulfills the following requirements:

- [X] Tested code with current [supported SDKs](../readme.md#supported)
- [ ] ~~Pull Request has been submitted to the documentation repository [instructions](..\contributing.md#docs). Link: <!-- docs PR link -->~~
- [ ] ~~Sample in sample app has been added / updated (for bug fixes / features)~~
    - [ ] ~~Icon has been created (if new sample) following the [Thumbnail Style Guide and templates](https://github.com/windows-toolkit/WindowsCommunityToolkit-design-assets)~~
- [ ] ~~Tests for the changes have been added (for bug fixes / features) (if applicable)~~
- [ ] ~~Header has been added to all new source files (run *build/UpdateHeaders.bat*)~~
- [X] Contains **NO** breaking changes
2020-10-06 10:42:35 +00:00
Sergio Pedri
b738cfd3af Merge branch 'master' into rename/guard-apis 2020-10-06 12:12:12 +02:00
Sergio Pedri
8b5ed6edca Fixed a bug in IBufferWriterStream.WriteByte 2020-10-05 23:00:54 +02:00
Sergio Pedri
045a6a94e8 Added buffer request unit tests 2020-10-05 22:17:32 +02:00
Sergio Pedri
0389a8ef9e Fixed ArrayPoolBufferWriter<T> repeated allocations 2020-10-05 22:02:45 +02:00
Sergio Pedri
bda2772426 Merge branch 'master' into feature/string-pool 2020-10-05 20:04:13 +02:00
Sergio Pedri
83f0672886 Fixed a build error in a unit test 2020-10-05 17:58:51 +02:00
Sergio Pedri
fa8446fe92 Added unit tests for IBufferWriterStream 2020-10-05 17:56:42 +02:00
Sergio Pedri
7774fb0ad8 Added IBufferWriter<byte>.AsStream extension 2020-10-05 17:30:44 +02:00
Sergio Pedri
95c82d52de Added IBufferWriterStream type 2020-10-05 17:26:23 +02:00
Sergio Pedri
f23573827b Added unit tests for StringMemoryManager<TTo> 2020-10-05 11:40:42 +02:00
Sergio Pedri
6403a848f7 Merge branch 'master' into feature/memory-cast 2020-10-05 10:31:38 +02:00
Sergio Pedri
1678529930 Added support for casting Memory<char> from string 2020-10-05 02:06:00 +02:00
Sergio Pedri
68d6648b14 Bug fixed in Pin methods, added unit tests 2020-10-05 00:52:42 +02:00
Sergio Pedri
db0f51a450 Added unit tests for slices and MemoryManager<T> 2020-10-04 20:32:51 +02:00
Sergio Pedri
ee3b885e2d Added unit test with types != byte 2020-10-04 18:58:58 +02:00
Sergio Pedri
06591855d4 Added some unit tests 2020-10-04 18:50:35 +02:00
Sergio Pedri
6464abf751 Fixed offset/length computation with double cast 2020-10-04 18:50:23 +02:00
Sergio Pedri
163168a30d Optimized [ReadOnly]Memory<T> cast to source T 2020-10-04 15:56:53 +02:00
Sergio Pedri
27b69aa612 Added [ReadOnly]Memory<T>.AsBytes extensions 2020-10-04 15:17:43 +02:00
Sergio Pedri
e026e71a22 Fixed type constraints for [ReadOnly]Span<T>.Cast 2020-10-04 15:13:54 +02:00
Sergio Pedri
13bca3daf0 Added validation for Pin methods 2020-10-04 13:58:50 +02:00
Sergio Pedri
ff33802ddb Added missing file headers 2020-10-04 13:50:02 +02:00
Sergio Pedri
53f5925cd6 Added the extension for ReadOnlyMemory<T> 2020-10-04 13:49:54 +02:00
Sergio Pedri
582a1f4597 Code refactoring 2020-10-04 13:45:16 +02:00
Sergio Pedri
7e810d1d4b Added initial version of Memory.Cast 2020-10-04 13:38:41 +02:00
msftbot[bot]
688032dc13 Support for nested/pointer/byref types for Type.ToTypeString() (#3468)
## Follow up for #3131 

<!-- Add a brief overview here of the feature/bug & fix. -->
The `Type.ToTypeString()` introduced with the `Guard` API lacks support for nested types, pointer types and byref types.

## PR Type
What kind of change does this PR introduce?
<!-- Please uncomment one or more that apply to this PR. -->

<!-- - Bugfix -->
<!-- - Feature -->
<!-- - Code style update (formatting) -->
<!-- - Refactoring (no functional changes, no api changes) -->
<!-- - Build or CI related changes -->
<!-- - Documentation content changes -->
<!-- - Sample app changes -->
<!-- - Other... Please describe: -->


## What is the current behavior?
<!-- Please describe the current behavior that you are modifying, or link to a relevant issue. -->
The extension doesn't work properly when used with nested, pointer or byref types.
It will either crash or just return the wrong formatted type (eg. the declaring type instead of the nested type).

## What is the new behavior?
<!-- Describe how was this issue resolved or changed? -->
The extension now works correctly with all sorts of nested, pointer and byref types 🎉

## PR Checklist

Please check if your PR fulfills the following requirements:

- [X] Tested code with current [supported SDKs](../readme.md#supported)
- [ ] ~~Pull Request has been submitted to the documentation repository [instructions](..\contributing.md#docs).~~
- [ ] ~~Sample in sample app has been added / updated (for bug fixes / features)~~
    - [ ] ~~Icon has been created (if new sample) following the [Thumbnail Style Guide and templates](https://github.com/windows-toolkit/WindowsCommunityToolkit-design-assets)~~
- [X] Tests for the changes have been added (for bug fixes / features) (if applicable)
- [X] Header has been added to all new source files (run *build/UpdateHeaders.bat*)
- [X] Contains **NO** breaking changes
2020-10-02 16:46:29 +00:00
Rosario Pulella
51a28969e2 Merge branch 'master' into bugfix/totypestring-extension 2020-10-02 12:13:27 -04:00
Sergio Pedri
e91ed46bb8 Code refactoring to WeakReferenceMessenger 2020-10-01 19:15:05 +02:00