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

Use nullable reference types #908

Merged
merged 3 commits into from
May 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Ix.NET/Source/AsyncQueryableGenerator.t4
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ return name;

var toQuoted = new Func<Type, int, string>((t, i) => toQuotedImpl(t, i, true));
#>
#nullable enable

using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
Expand Down Expand Up @@ -154,7 +156,7 @@ foreach (var m in asyncEnumerableType.GetMethods()
}
}

var pars = string.Join(", ", m.GetParameters().Select((p, i) => (i == parCount - 1 && isParams ? "params " : "") + toQuoted(p.ParameterType, i) + " " + p.Name + (i == parCount - 1 && lastParameterDefault ? " = default" : "")));
var pars = string.Join(", ", m.GetParameters().Select((p, i) => (i == parCount - 1 && isParams ? "params " : "") + toQuoted(p.ParameterType, i) + (nullableParameterNames.Contains(p.Name) ? "?" : "") + " " + p.Name + (i == parCount - 1 && lastParameterDefault ? " = default" : "")));
var quotedPars = string.Join(", ", m.GetParameters().Select((p, i) => "default(" + toQuoted(p.ParameterType, i) + ")"));

if (m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<AssemblyTitle>Interactive Extensions - Async Providers Library</AssemblyTitle>
<TargetFrameworks>net461;netstandard2.0;netstandard2.1;netcoreapp3.0</TargetFrameworks>
<PackageTags>Ix;Interactive;Extensions;Enumerable;Asynchronous</PackageTags>
<NullableContextOptions>enable</NullableContextOptions>
</PropertyGroup>

<ItemGroup>
Expand All @@ -21,4 +22,8 @@
<Compile Update="System\Linq\AsyncQueryableEx.Generated.cs" DesignTime="True" AutoGen="True" DependentUpon="AsyncQueryableEx.Generated.tt" />
</ItemGroup>

<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.

#nullable enable

using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
Expand Down Expand Up @@ -188,7 +190,7 @@ private static MethodInfo Distinct__TSource_TKey__3__0(Type TSource, Type TKey)
(s_Distinct__TSource_TKey__3__0 ??
(s_Distinct__TSource_TKey__3__0 = new Func<IAsyncQueryable<object>, Expression<Func<object, CancellationToken, ValueTask<object>>>, IEqualityComparer<object>, IAsyncQueryable<object>>(Distinct<object, object>).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey);

public static IAsyncQueryable<TSource> Distinct<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, CancellationToken, ValueTask<TKey>>> keySelector, IEqualityComparer<TKey> comparer)
public static IAsyncQueryable<TSource> Distinct<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, CancellationToken, ValueTask<TKey>>> keySelector, IEqualityComparer<TKey>? comparer)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
Expand All @@ -204,7 +206,7 @@ private static MethodInfo Distinct__TSource_TKey__3__1(Type TSource, Type TKey)
(s_Distinct__TSource_TKey__3__1 ??
(s_Distinct__TSource_TKey__3__1 = new Func<IAsyncQueryable<object>, Expression<Func<object, object>>, IEqualityComparer<object>, IAsyncQueryable<object>>(Distinct<object, object>).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey);

public static IAsyncQueryable<TSource> Distinct<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
public static IAsyncQueryable<TSource> Distinct<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey>? comparer)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
Expand All @@ -220,7 +222,7 @@ private static MethodInfo Distinct__TSource_TKey__3__2(Type TSource, Type TKey)
(s_Distinct__TSource_TKey__3__2 ??
(s_Distinct__TSource_TKey__3__2 = new Func<IAsyncQueryable<object>, Expression<Func<object, ValueTask<object>>>, IEqualityComparer<object>, IAsyncQueryable<object>>(Distinct<object, object>).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey);

public static IAsyncQueryable<TSource> Distinct<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, ValueTask<TKey>>> keySelector, IEqualityComparer<TKey> comparer)
public static IAsyncQueryable<TSource> Distinct<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, ValueTask<TKey>>> keySelector, IEqualityComparer<TKey>? comparer)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
Expand Down Expand Up @@ -250,7 +252,7 @@ private static MethodInfo DistinctUntilChanged__TSource__2__0(Type TSource) =>
(s_DistinctUntilChanged__TSource__2__0 ??
(s_DistinctUntilChanged__TSource__2__0 = new Func<IAsyncQueryable<object>, IEqualityComparer<object>, IAsyncQueryable<object>>(DistinctUntilChanged<object>).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource);

public static IAsyncQueryable<TSource> DistinctUntilChanged<TSource>(this IAsyncQueryable<TSource> source, IEqualityComparer<TSource> comparer)
public static IAsyncQueryable<TSource> DistinctUntilChanged<TSource>(this IAsyncQueryable<TSource> source, IEqualityComparer<TSource>? comparer)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
Expand Down Expand Up @@ -312,7 +314,7 @@ private static MethodInfo DistinctUntilChanged__TSource_TKey__3__0(Type TSource,
(s_DistinctUntilChanged__TSource_TKey__3__0 ??
(s_DistinctUntilChanged__TSource_TKey__3__0 = new Func<IAsyncQueryable<object>, Expression<Func<object, CancellationToken, ValueTask<object>>>, IEqualityComparer<object>, IAsyncQueryable<object>>(DistinctUntilChanged<object, object>).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey);

public static IAsyncQueryable<TSource> DistinctUntilChanged<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, CancellationToken, ValueTask<TKey>>> keySelector, IEqualityComparer<TKey> comparer)
public static IAsyncQueryable<TSource> DistinctUntilChanged<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, CancellationToken, ValueTask<TKey>>> keySelector, IEqualityComparer<TKey>? comparer)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
Expand All @@ -328,7 +330,7 @@ private static MethodInfo DistinctUntilChanged__TSource_TKey__3__1(Type TSource,
(s_DistinctUntilChanged__TSource_TKey__3__1 ??
(s_DistinctUntilChanged__TSource_TKey__3__1 = new Func<IAsyncQueryable<object>, Expression<Func<object, object>>, IEqualityComparer<object>, IAsyncQueryable<object>>(DistinctUntilChanged<object, object>).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey);

public static IAsyncQueryable<TSource> DistinctUntilChanged<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
public static IAsyncQueryable<TSource> DistinctUntilChanged<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey>? comparer)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
Expand All @@ -344,7 +346,7 @@ private static MethodInfo DistinctUntilChanged__TSource_TKey__3__2(Type TSource,
(s_DistinctUntilChanged__TSource_TKey__3__2 ??
(s_DistinctUntilChanged__TSource_TKey__3__2 = new Func<IAsyncQueryable<object>, Expression<Func<object, ValueTask<object>>>, IEqualityComparer<object>, IAsyncQueryable<object>>(DistinctUntilChanged<object, object>).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey);

public static IAsyncQueryable<TSource> DistinctUntilChanged<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, ValueTask<TKey>>> keySelector, IEqualityComparer<TKey> comparer)
public static IAsyncQueryable<TSource> DistinctUntilChanged<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, ValueTask<TKey>>> keySelector, IEqualityComparer<TKey>? comparer)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
Expand Down Expand Up @@ -700,7 +702,7 @@ private static MethodInfo MaxAsync__TSource__3__0(Type TSource) =>
(s_MaxAsync__TSource__3__0 ??
(s_MaxAsync__TSource__3__0 = new Func<IAsyncQueryable<object>, IComparer<object>, CancellationToken, ValueTask<object>>(MaxAsync<object>).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource);

public static ValueTask<TSource> MaxAsync<TSource>(this IAsyncQueryable<TSource> source, IComparer<TSource> comparer, CancellationToken cancellationToken = default)
public static ValueTask<TSource> MaxAsync<TSource>(this IAsyncQueryable<TSource> source, IComparer<TSource>? comparer, CancellationToken cancellationToken = default)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
Expand Down Expand Up @@ -762,7 +764,7 @@ private static MethodInfo MaxByAsync__TSource_TKey__4__0(Type TSource, Type TKey
(s_MaxByAsync__TSource_TKey__4__0 ??
(s_MaxByAsync__TSource_TKey__4__0 = new Func<IAsyncQueryable<object>, Expression<Func<object, CancellationToken, ValueTask<object>>>, IComparer<object>, CancellationToken, ValueTask<IList<object>>>(MaxByAsync<object, object>).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey);

public static ValueTask<IList<TSource>> MaxByAsync<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, CancellationToken, ValueTask<TKey>>> keySelector, IComparer<TKey> comparer, CancellationToken cancellationToken = default)
public static ValueTask<IList<TSource>> MaxByAsync<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, CancellationToken, ValueTask<TKey>>> keySelector, IComparer<TKey>? comparer, CancellationToken cancellationToken = default)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
Expand All @@ -778,7 +780,7 @@ private static MethodInfo MaxByAsync__TSource_TKey__4__1(Type TSource, Type TKey
(s_MaxByAsync__TSource_TKey__4__1 ??
(s_MaxByAsync__TSource_TKey__4__1 = new Func<IAsyncQueryable<object>, Expression<Func<object, object>>, IComparer<object>, CancellationToken, ValueTask<IList<object>>>(MaxByAsync<object, object>).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey);

public static ValueTask<IList<TSource>> MaxByAsync<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer, CancellationToken cancellationToken = default)
public static ValueTask<IList<TSource>> MaxByAsync<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey>? comparer, CancellationToken cancellationToken = default)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
Expand All @@ -794,7 +796,7 @@ private static MethodInfo MaxByAsync__TSource_TKey__4__2(Type TSource, Type TKey
(s_MaxByAsync__TSource_TKey__4__2 ??
(s_MaxByAsync__TSource_TKey__4__2 = new Func<IAsyncQueryable<object>, Expression<Func<object, ValueTask<object>>>, IComparer<object>, CancellationToken, ValueTask<IList<object>>>(MaxByAsync<object, object>).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey);

public static ValueTask<IList<TSource>> MaxByAsync<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, ValueTask<TKey>>> keySelector, IComparer<TKey> comparer, CancellationToken cancellationToken = default)
public static ValueTask<IList<TSource>> MaxByAsync<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, ValueTask<TKey>>> keySelector, IComparer<TKey>? comparer, CancellationToken cancellationToken = default)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
Expand Down Expand Up @@ -824,7 +826,7 @@ private static MethodInfo MinAsync__TSource__3__0(Type TSource) =>
(s_MinAsync__TSource__3__0 ??
(s_MinAsync__TSource__3__0 = new Func<IAsyncQueryable<object>, IComparer<object>, CancellationToken, ValueTask<object>>(MinAsync<object>).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource);

public static ValueTask<TSource> MinAsync<TSource>(this IAsyncQueryable<TSource> source, IComparer<TSource> comparer, CancellationToken cancellationToken = default)
public static ValueTask<TSource> MinAsync<TSource>(this IAsyncQueryable<TSource> source, IComparer<TSource>? comparer, CancellationToken cancellationToken = default)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
Expand Down Expand Up @@ -886,7 +888,7 @@ private static MethodInfo MinByAsync__TSource_TKey__4__0(Type TSource, Type TKey
(s_MinByAsync__TSource_TKey__4__0 ??
(s_MinByAsync__TSource_TKey__4__0 = new Func<IAsyncQueryable<object>, Expression<Func<object, CancellationToken, ValueTask<object>>>, IComparer<object>, CancellationToken, ValueTask<IList<object>>>(MinByAsync<object, object>).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey);

public static ValueTask<IList<TSource>> MinByAsync<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, CancellationToken, ValueTask<TKey>>> keySelector, IComparer<TKey> comparer, CancellationToken cancellationToken = default)
public static ValueTask<IList<TSource>> MinByAsync<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, CancellationToken, ValueTask<TKey>>> keySelector, IComparer<TKey>? comparer, CancellationToken cancellationToken = default)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
Expand All @@ -902,7 +904,7 @@ private static MethodInfo MinByAsync__TSource_TKey__4__1(Type TSource, Type TKey
(s_MinByAsync__TSource_TKey__4__1 ??
(s_MinByAsync__TSource_TKey__4__1 = new Func<IAsyncQueryable<object>, Expression<Func<object, object>>, IComparer<object>, CancellationToken, ValueTask<IList<object>>>(MinByAsync<object, object>).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey);

public static ValueTask<IList<TSource>> MinByAsync<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer, CancellationToken cancellationToken = default)
public static ValueTask<IList<TSource>> MinByAsync<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey>? comparer, CancellationToken cancellationToken = default)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
Expand All @@ -918,7 +920,7 @@ private static MethodInfo MinByAsync__TSource_TKey__4__2(Type TSource, Type TKey
(s_MinByAsync__TSource_TKey__4__2 ??
(s_MinByAsync__TSource_TKey__4__2 = new Func<IAsyncQueryable<object>, Expression<Func<object, ValueTask<object>>>, IComparer<object>, CancellationToken, ValueTask<IList<object>>>(MinByAsync<object, object>).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey);

public static ValueTask<IList<TSource>> MinByAsync<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, ValueTask<TKey>>> keySelector, IComparer<TKey> comparer, CancellationToken cancellationToken = default)
public static ValueTask<IList<TSource>> MinByAsync<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, ValueTask<TKey>>> keySelector, IComparer<TKey>? comparer, CancellationToken cancellationToken = default)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
// See the LICENSE file in the project root for more information.

<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Threading.Tasks.Extensions.dll" #>
<#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Linq.Async.dll" #>
<#@ assembly name="$(ProjectDir)\..\System.Interactive.Async\bin\$(Configuration)\net46\System.Interactive.Async.dll" #>
<#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net461\Microsoft.Bcl.AsyncInterfaces.dll" #>
<#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net461\System.Threading.Tasks.Extensions.dll" #>
<#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net461\System.Linq.Async.dll" #>
<#@ assembly name="$(ProjectDir)\..\System.Interactive.Async\bin\$(Configuration)\net461\System.Interactive.Async.dll" #>
<#@ output extension=".cs" #>
<#
var asyncEnumerableType = typeof(AsyncEnumerableEx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<AssemblyTitle>Interactive Extensions - Async Library</AssemblyTitle>
<TargetFrameworks>net461;netstandard2.0;netstandard2.1;netcoreapp3.0</TargetFrameworks>
<PackageTags>Ix;Interactive;Extensions;Enumerable;Asynchronous</PackageTags>
<NullableContextOptions>enable</NullableContextOptions>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public static IAsyncEnumerable<TSource> Amb<TSource>(this IAsyncEnumerable<TSour

async IAsyncEnumerator<TSource> Core(CancellationToken cancellationToken)
{
IAsyncEnumerator<TSource> firstEnumerator = null;
IAsyncEnumerator<TSource> secondEnumerator = null;
IAsyncEnumerator<TSource>? firstEnumerator = null;
IAsyncEnumerator<TSource>? secondEnumerator = null;

Task<bool> firstMoveNext = null;
Task<bool> secondMoveNext = null;
Task<bool>? firstMoveNext = null;
Task<bool>? secondMoveNext = null;

try
{
Expand Down Expand Up @@ -228,7 +228,7 @@ public static IAsyncEnumerable<TSource> Amb<TSource>(this IEnumerable<IAsyncEnum
return Amb(sources.ToArray());
}

private static async Task AwaitMoveNextAsyncAndDispose<T>(Task<bool> moveNextAsync, IAsyncEnumerator<T> enumerator)
private static async Task AwaitMoveNextAsyncAndDispose<T>(Task<bool>? moveNextAsync, IAsyncEnumerator<T>? enumerator)
{
if (enumerator != null)
{
Expand Down
Loading