-
Notifications
You must be signed in to change notification settings - Fork 418
Annotate nullability of reference types #582
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
Merged
Merged
Changes from all commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
13994f4
Use C# 8
atifaziz 9fbb80d
Annotate nullability of reference types
atifaziz 52406ab
Use VS 2019 Preview image for AppVeyor
atifaziz 30e06c4
Install .NET Core SDK on AppVeyor
atifaziz 6b4468e
Don't send telemetry data
atifaziz b37e941
Prevent dotnet from pre-populating packages cache
atifaziz 8328713
Use dotnet (instead of MSBuild) for main build
atifaziz cd955b2
Revert to VS 2017 image on AppVeyor
atifaziz 0f3405e
Use dotnet CLI for packing
atifaziz 3bb9293
Merge branch 'master' into nullability
atifaziz e15c498
Use VS 2019 image for AppVeyor
atifaziz c24d362
Merge branch 'master' into nullability
atifaziz a337fd6
Review ScanBy for nullable reference types
atifaziz 320bb9a
Simplify Count/ScanBy patterns
atifaziz 11f704c
Merge remote-tracking branch 'MoreLinqRepo/master' into nullability
Orace 9723435
Use <Nullable> instead of <NullableContextOptions>
Orace 311b5e3
Fix build
Orace 22f358e
Fix c#8 nullable-default
moh-hassan 03e0d35
Merge branch 'master' of https://github.com/moh-hassan/MoreLINQ into …
moh-hassan 24375db
Add Nullable attributes from Nullable package.
moh-hassan 6c08614
Resolve appveyor CI of "unexpected trailing whitespace"
moh-hassan 68d152b
modify Extensions.g.cs and set nullability
moh-hassan 467426f
Merge branch 'master' into nullability
atifaziz 97d424d
Fix build errors from previous merge
atifaziz e8669c2
Revert change in Subject visibility
atifaziz fe52462
Revert changes to Await, Flatten & Memoize
atifaziz 406a256
Revert some uses of dammit (!)
atifaziz 347b752
Add to-do review note for TrySingle
atifaziz 22ca363
Fix enumerators type in Transpose
atifaziz f003d51
Revert change to condition in PartialSort
atifaziz aea5493
Remove unused namespace post removal of assertions
atifaziz cca9227
Require .NET Core SDK 3.1.300
atifaziz 3d602b9
Simplify variable declaration/init
atifaziz 939686f
Remove need for dammit (!) in FillForward
atifaziz b8303de
Remove need for dammit (!) in GroupAdjacent
atifaziz 9725078
Revert assert removal
atifaziz ea9f318
Remove need for dammit (!) in ScanBy
atifaziz 948c83c
Add minimal null-aware dictionary wrapper
atifaziz 88be3ac
Extract & reuse dict wrapper in CountBy
atifaziz 38437b3
Add missing Collections file
atifaziz e4a4922
Fix type of DelegatingDisposable field
atifaziz 3c6282e
Revert most EndsWith edits
atifaziz 8439ced
Revert unrelated edit in Await
atifaziz 0c3e2e8
Note why "#nullable enable" is needed for generated code
atifaziz d596449
Remove extra blank line
atifaziz b87b381
Remove need for dammit (!) in FallbackIfEmpty
atifaziz 5fbe0f0
Revert unneeded change in FillBackward
atifaziz b2486f2
More honest "Extrema<,>" in light of nullability
atifaziz cda81f0
Revert unrelated style changes in OrderBy
atifaziz c6d59ff
Reduce one dammit (!) via better PartialSort/By
atifaziz 4d27c75
Move empty array class to own file
atifaziz a534a9b
Revert changes to generator project
atifaziz 2e5edfc
Remove need for dammit (!) in ZipImpl
atifaziz 1ae5275
Revert "Remove need for dammit (!) in ZipImpl"
atifaziz 7644df2
Revert some accidental changes in 3d602b9
atifaziz baade11
Note about disallowing ToDataTable expressions to be null
atifaziz b0ea8ee
First/Single/LastOrDefault may return nullable
atifaziz 903a07f
Merge branch 'master' into nullability
atifaziz 861585c
Make Dictionary more honest (convert to class)
atifaziz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#region License and Terms | ||
// MoreLINQ - Extensions to LINQ to Objects | ||
// Copyright (c) 2020 Atif Aziz, Leandro F. Vieira (leandromoh). All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
#endregion | ||
|
||
namespace MoreLinq.Collections | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
/// <summary> | ||
/// A minimal <see cref="System.Collections.Generic.Dictionary{TKey,TValue}"/> wrapper that | ||
/// allows null keys when <typeparamref name="TKey"/> is a | ||
/// reference type. | ||
/// </summary> | ||
|
||
// Add members if and when needed to keep coverage. | ||
|
||
sealed class Dictionary<TKey, TValue> | ||
{ | ||
readonly System.Collections.Generic.Dictionary<TKey, TValue> _dict; | ||
(bool, TValue) _null; | ||
|
||
public Dictionary(IEqualityComparer<TKey> comparer) | ||
{ | ||
_dict = new System.Collections.Generic.Dictionary<TKey, TValue>(comparer); | ||
_null = default; | ||
} | ||
|
||
public TValue this[TKey key] | ||
{ | ||
set | ||
{ | ||
if (key is null) | ||
_null = (true, value); | ||
else | ||
_dict[key] = value; | ||
} | ||
} | ||
|
||
public bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value) | ||
{ | ||
if (key is null) | ||
{ | ||
switch (_null) | ||
fsateler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
case (true, {} v): | ||
value = v; | ||
return true; | ||
case (false, _): | ||
value = default!; | ||
return false; | ||
} | ||
} | ||
|
||
return _dict.TryGetValue(key, out value); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace MoreLinq | ||
{ | ||
static class EmptyArray<T> | ||
{ | ||
public static readonly T[] Value = new T[0]; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.