Skip to content

Commit

Permalink
Target netstandard2.1
Browse files Browse the repository at this point in the history
Microsoft.Data.Sqlite & EF tools are left intact.
Most of the changes are related to breaking change on interface which IX-Async gave us and which is in built
  • Loading branch information
smitpatel committed Jun 4, 2019
1 parent 7081516 commit 49d8905
Show file tree
Hide file tree
Showing 33 changed files with 583 additions and 406 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net461;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(Configuration)' == 'Release' Or '$(Configuration)' == 'Debug' ">netcoreapp3.0</TargetFrameworks>
<RootNamespace>Microsoft.EntityFrameworkCore.Benchmarks</RootNamespace>
<OutputType>Exe</OutputType>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net461;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(Configuration)' == 'Release' Or '$(Configuration)' == 'Debug' ">netcoreapp3.0</TargetFrameworks>
<RootNamespace>Microsoft.EntityFrameworkCore.Benchmarks</RootNamespace>
<OutputType>Exe</OutputType>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Abstractions/EFCore.Abstractions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>Provides abstractions and attributes that are used to configure Entity Framework Core</Description>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<MinClientVersion>3.6</MinClientVersion>
<AssemblyName>Microsoft.EntityFrameworkCore.Abstractions</AssemblyName>
<RootNamespace>Microsoft.EntityFrameworkCore</RootNamespace>
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/EFCore.Cosmos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>Azure Cosmos provider for Entity Framework Core.</Description>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<MinClientVersion>3.6</MinClientVersion>
<AssemblyName>Microsoft.EntityFrameworkCore.Cosmos</AssemblyName>
<RootNamespace>Microsoft.EntityFrameworkCore.Cosmos</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,28 @@ public AsyncShaperEnumerable(
_shaper = shaper;
}

public IAsyncEnumerator<T> GetEnumerator() => new AsyncShaperEnumerator(this);
public IAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{
return new AsyncShaperEnumerator(this, cancellationToken);
}

private class AsyncShaperEnumerator : IAsyncEnumerator<T>
{
private readonly IAsyncEnumerator<JObject> _enumerator;
private readonly Func<JObject, T> _shaper;

public AsyncShaperEnumerator(AsyncShaperEnumerable<T> enumerable)
public AsyncShaperEnumerator(AsyncShaperEnumerable<T> enumerable, CancellationToken cancellationToken)
{
_enumerator = enumerable._innerEnumerable.GetEnumerator();
_enumerator = enumerable._innerEnumerable.GetAsyncEnumerator(cancellationToken);
_shaper = enumerable._shaper;
}

public T Current { get; private set; }

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public async Task<bool> MoveNext(CancellationToken cancellationToken)
public async ValueTask<bool> MoveNextAsync()
{
if (!await _enumerator.MoveNext(cancellationToken))
if (!await _enumerator.MoveNextAsync())
{
Current = default;
return false;
Expand All @@ -108,9 +113,12 @@ public async Task<bool> MoveNext(CancellationToken cancellationToken)
return true;
}

public T Current { get; private set; }
public ValueTask DisposeAsync()
{
_enumerator.DisposeAsync();

public void Dispose() => _enumerator.Dispose();
return default;
}
}
}

Expand Down
23 changes: 13 additions & 10 deletions src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ public DocumentAsyncEnumerable(
_cosmosSqlQuery = cosmosSqlQuery;
}

public IAsyncEnumerator<JObject> GetEnumerator() => new AsyncEnumerator(this);

public IAsyncEnumerator<JObject> GetAsyncEnumerator(CancellationToken cancellationToken = default)
=> new AsyncEnumerator(this, cancellationToken);
private class AsyncEnumerator : IAsyncEnumerator<JObject>
{
private CosmosResultSetIterator _query;
Expand All @@ -439,20 +439,23 @@ private class AsyncEnumerator : IAsyncEnumerator<JObject>
private readonly CosmosClientWrapper _cosmosClient;
private readonly string _containerId;
private readonly CosmosSqlQuery _cosmosSqlQuery;
private readonly CancellationToken _cancellationToken;

public AsyncEnumerator(DocumentAsyncEnumerable documentEnumerable)
public AsyncEnumerator(DocumentAsyncEnumerable documentEnumerable, CancellationToken cancellationToken)
{
_cosmosClient = documentEnumerable._cosmosClient;
_containerId = documentEnumerable._containerId;
_cosmosSqlQuery = documentEnumerable._cosmosSqlQuery;
_cancellationToken = cancellationToken;
}

public JObject Current { get; private set; }


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public async Task<bool> MoveNext(CancellationToken cancellationToken)
public async ValueTask<bool> MoveNextAsync()
{
cancellationToken.ThrowIfCancellationRequested();
_cancellationToken.ThrowIfCancellationRequested();

if (_jsonReader == null)
{
Expand All @@ -467,7 +470,7 @@ public async Task<bool> MoveNext(CancellationToken cancellationToken)
return false;
}

_responseStream = (await _query.FetchNextSetAsync(cancellationToken)).Content;
_responseStream = (await _query.FetchNextSetAsync(_cancellationToken)).Content;
_reader = new StreamReader(_responseStream);
_jsonReader = new JsonTextReader(_reader);

Expand Down Expand Up @@ -510,20 +513,20 @@ public async Task<bool> MoveNext(CancellationToken cancellationToken)
_reader = null;
_responseStream.Dispose();
_responseStream = null;
return await MoveNext(cancellationToken);
return await MoveNextAsync();
}

public void Dispose()
public ValueTask DisposeAsync()
{
_jsonReader?.Close();
_jsonReader = null;
_reader?.Dispose();
_reader = null;
_responseStream?.Dispose();
_responseStream = null;
}

public void Reset() => throw new NotImplementedException();
return default;
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/EFCore.Design/EFCore.Design.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>Shared design-time components for Entity Framework Core tools.</Description>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<AssemblyName>Microsoft.EntityFrameworkCore.Design</AssemblyName>
<RootNamespace>Microsoft.EntityFrameworkCore</RootNamespace>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand All @@ -20,7 +20,7 @@
<PackagePath>build</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\EFCore.Relational\EFCore.Relational.csproj" PrivateAssets="contentfiles;build" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.InMemory/EFCore.InMemory.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>In-memory database provider for Entity Framework Core (to be used for testing purposes).</Description>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<MinClientVersion>3.6</MinClientVersion>
<AssemblyName>Microsoft.EntityFrameworkCore.InMemory</AssemblyName>
<RootNamespace>Microsoft.EntityFrameworkCore.InMemory</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ public AsyncQueryingEnumerable(
_logger = logger;
}

public IAsyncEnumerator<T> GetEnumerator() => new AsyncEnumerator(this);
public IAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default)
=> new AsyncEnumerator(this, cancellationToken);

private sealed class AsyncEnumerator : IAsyncEnumerator<T>
{
Expand All @@ -242,21 +243,23 @@ private sealed class AsyncEnumerator : IAsyncEnumerator<T>
private readonly Func<QueryContext, IEnumerator<ValueBuffer>, Task<T>> _shaper;
private readonly Type _contextType;
private readonly IDiagnosticsLogger<DbLoggerCategory.Query> _logger;
private readonly CancellationToken _cancellationToken;

public AsyncEnumerator(AsyncQueryingEnumerable<T> asyncQueryingEnumerable)
public AsyncEnumerator(
AsyncQueryingEnumerable<T> asyncQueryingEnumerable,
CancellationToken cancellationToken)
{
_queryContext = asyncQueryingEnumerable._queryContext;
_innerEnumerable = asyncQueryingEnumerable._innerEnumerable;
_shaper = asyncQueryingEnumerable._shaper;
_contextType = asyncQueryingEnumerable._contextType;
_logger = asyncQueryingEnumerable._logger;
_cancellationToken = cancellationToken;
}

public T Current { get; private set; }

public void Dispose() => _enumerator?.Dispose();

public async Task<bool> MoveNext(CancellationToken cancellationToken)
public async ValueTask<bool> MoveNextAsync()
{
try
{
Expand All @@ -280,6 +283,13 @@ public async Task<bool> MoveNext(CancellationToken cancellationToken)
throw;
}
}

public ValueTask DisposeAsync()
{
_enumerator?.Dispose();

return default;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Proxies/EFCore.Proxies.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>Lazy-loading proxies for EF Core.</Description>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<MinClientVersion>3.6</MinClientVersion>
<AssemblyName>Microsoft.EntityFrameworkCore.Proxies</AssemblyName>
<RootNamespace>Microsoft.EntityFrameworkCore</RootNamespace>
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Relational/EFCore.Relational.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>Shared Entity Framework Core components for relational database providers.</Description>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<MinClientVersion>3.6</MinClientVersion>
<AssemblyName>Microsoft.EntityFrameworkCore.Relational</AssemblyName>
<RootNamespace>Microsoft.EntityFrameworkCore</RootNamespace>
Expand Down
33 changes: 20 additions & 13 deletions src/EFCore.Relational/Query/Pipeline/AsyncQueryingEnumerable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public AsyncQueryingEnumerable(
_logger = logger;
}

public IAsyncEnumerator<T> GetEnumerator() => new AsyncEnumerator(this);
public IAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default)
=> new AsyncEnumerator(this, cancellationToken);

private sealed class AsyncEnumerator : IAsyncEnumerator<T>
{
Expand All @@ -60,8 +61,11 @@ private sealed class AsyncEnumerator : IAsyncEnumerator<T>
private readonly IDiagnosticsLogger<DbLoggerCategory.Query> _logger;
private readonly ISqlExpressionFactory _sqlExpressionFactory;
private readonly IParameterNameGeneratorFactory _parameterNameGeneratorFactory;
private readonly CancellationToken _cancellationToken;

public AsyncEnumerator(AsyncQueryingEnumerable<T> queryingEnumerable)
public AsyncEnumerator(
AsyncQueryingEnumerable<T> queryingEnumerable,
CancellationToken cancellationToken)
{
_relationalQueryContext = queryingEnumerable._relationalQueryContext;
_shaper = queryingEnumerable._shaper;
Expand All @@ -71,24 +75,18 @@ public AsyncEnumerator(AsyncQueryingEnumerable<T> queryingEnumerable)
_logger = queryingEnumerable._logger;
_sqlExpressionFactory = queryingEnumerable._sqlExpressionFactory;
_parameterNameGeneratorFactory = queryingEnumerable._parameterNameGeneratorFactory;
_cancellationToken = cancellationToken;
}

public T Current { get; private set; }

public void Dispose()
{
_dataReader?.Dispose();
_dataReader = null;
_relationalQueryContext.Connection.Close();
}

public async Task<bool> MoveNext(CancellationToken cancellationToken)
public async ValueTask<bool> MoveNextAsync()
{
try
{
if (_dataReader == null)
{
await _relationalQueryContext.Connection.OpenAsync(cancellationToken);
await _relationalQueryContext.Connection.OpenAsync(_cancellationToken);

try
{
Expand All @@ -104,7 +102,7 @@ public async Task<bool> MoveNext(CancellationToken cancellationToken)
_relationalQueryContext.Connection,
_relationalQueryContext.ParameterValues,
_relationalQueryContext.CommandLogger,
cancellationToken);
_cancellationToken);

_resultCoordinator = new ResultCoordinator();
}
Expand All @@ -118,7 +116,7 @@ public async Task<bool> MoveNext(CancellationToken cancellationToken)
}
}

var hasNext = _resultCoordinator.HasNext ?? await _dataReader.ReadAsync(cancellationToken);
var hasNext = _resultCoordinator.HasNext ?? await _dataReader.ReadAsync(_cancellationToken);
_resultCoordinator.HasNext = null;

Current
Expand All @@ -135,6 +133,15 @@ public async Task<bool> MoveNext(CancellationToken cancellationToken)
throw;
}
}

public ValueTask DisposeAsync()
{
_dataReader?.Dispose();
_dataReader = null;
_relationalQueryContext.Connection.Close();

return default;
}
}
}
}
Expand Down
Loading

0 comments on commit 49d8905

Please sign in to comment.