Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable

using Microsoft.EntityFrameworkCore.Cosmos.Diagnostics.Internal;
using Microsoft.EntityFrameworkCore.Cosmos.Extensions.Internal;
using CosmosSqlQuery = Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal.CosmosSqlQuery;
Expand Down Expand Up @@ -93,7 +91,7 @@ private sealed class AsyncEnumerator : IAsyncEnumerator<CosmosPage<T>>
private readonly IDiagnosticsLogger<DbLoggerCategory.Database.Command> _commandLogger;
private readonly bool _standAloneStateManager;
private readonly CancellationToken _cancellationToken;
private readonly IConcurrencyDetector _concurrencyDetector;
private readonly IConcurrencyDetector? _concurrencyDetector;
private readonly IExceptionDetector _exceptionDetector;

private bool _hasExecuted;
Expand Down Expand Up @@ -135,9 +133,9 @@ public async ValueTask<bool> MoveNextAsync()

_hasExecuted = true;

var maxItemCount = (int)_cosmosQueryContext.Parameters[_queryingEnumerable._maxItemCountParameterName];
var maxItemCount = (int)_cosmosQueryContext.Parameters[_queryingEnumerable._maxItemCountParameterName]!;
var continuationToken =
(string)_cosmosQueryContext.Parameters[_queryingEnumerable._continuationTokenParameterName];
(string?)_cosmosQueryContext.Parameters[_queryingEnumerable._continuationTokenParameterName];
var responseContinuationTokenLimitInKb = (int?)
_cosmosQueryContext.Parameters[_queryingEnumerable._responseContinuationTokenLimitInKbParameterName];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable

using System.Collections;

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal;
Expand All @@ -11,7 +9,7 @@ public partial class CosmosShapedQueryCompilingExpressionVisitor
{
private sealed class ParameterInliner(
ISqlExpressionFactory sqlExpressionFactory,
IReadOnlyDictionary<string, object> parametersValues)
IReadOnlyDictionary<string, object?> parametersValues)
: ExpressionVisitor
{
protected override Expression VisitExtension(Expression expression)
Expand All @@ -37,7 +35,7 @@ protected override Expression VisitExtension(Expression expression)
{
var typeMapping = valuesParameter.TypeMapping;
var mutableValues = new List<SqlExpression>();
foreach (var value in (IEnumerable)parametersValues[valuesParameter.Name])
foreach (var value in (IEnumerable)parametersValues[valuesParameter.Name]!)
{
mutableValues.Add(sqlExpressionFactory.Constant(value, value?.GetType() ?? typeof(object), typeMapping));
}
Expand Down Expand Up @@ -68,15 +66,15 @@ protected override Expression VisitExtension(Expression expression)
{
hybridSearch.ApplyLimit(
sqlExpressionFactory.Constant(
parametersValues[limitPrm.Name],
parametersValues[limitPrm.Name]!,
limitPrm.TypeMapping));
}

if (hybridSearch.Offset is SqlParameterExpression offsetPrm)
{
hybridSearch.ApplyOffset(
sqlExpressionFactory.Constant(
parametersValues[offsetPrm.Name],
parametersValues[offsetPrm.Name]!,
offsetPrm.TypeMapping));
}

Expand All @@ -98,7 +96,7 @@ protected override Expression VisitExtension(Expression expression)
when (name is "FullTextContainsAny" or "FullTextContainsAll" or "FullTextScore") && type == typeof(string[]):
{
var keywordValues = new List<SqlExpression>();
foreach (var value in (IEnumerable)parametersValues[keywords.Name])
foreach (var value in (IEnumerable)parametersValues[keywords.Name]!)
{
keywordValues.Add(sqlExpressionFactory.Constant(value, typeof(string), elementTypeMapping));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable

using System.Collections;
using Microsoft.EntityFrameworkCore.Cosmos.Internal;
using Microsoft.EntityFrameworkCore.Cosmos.Metadata.Internal;
Expand Down Expand Up @@ -77,7 +75,7 @@ private bool TryGetResourceId(out string resourceId)
jsonIdDefinition != null,
"Should not be using this enumerable if not using ReadItem, which needs an id definition.");

var values = new List<object>(jsonIdDefinition.Properties.Count);
var values = new List<object?>(jsonIdDefinition.Properties.Count);
foreach (var property in jsonIdDefinition.Properties)
{
var value = _readItemInfo.PropertyValues[property] switch
Expand All @@ -103,7 +101,7 @@ private sealed class AsyncEnumerator : IAsyncEnumerator<T>
private readonly Type _contextType;
private readonly IDiagnosticsLogger<DbLoggerCategory.Query> _queryLogger;
private readonly bool _standAloneStateManager;
private readonly IConcurrencyDetector _concurrencyDetector;
private readonly IConcurrencyDetector? _concurrencyDetector;
private readonly IExceptionDetector _exceptionDetector;
private readonly ReadItemQueryingEnumerable<T> _readItemEnumerable;
private readonly CancellationToken _cancellationToken;
Expand All @@ -123,6 +121,7 @@ public AsyncEnumerator(ReadItemQueryingEnumerable<T> readItemEnumerable, Cancell
_exceptionDetector = _cosmosQueryContext.ExceptionDetector;
_readItemEnumerable = readItemEnumerable;
_cancellationToken = cancellationToken;
Current = default!;

_concurrencyDetector = readItemEnumerable._threadSafetyChecksEnabled
? _cosmosQueryContext.ConcurrencyDetector
Expand Down Expand Up @@ -187,18 +186,20 @@ public void Reset()

private bool ShapeResult()
{
var hasNext = _response is not null;

_cosmosQueryContext.InitializeStateManager(_standAloneStateManager);

Current
= hasNext
? _shaper(_cosmosQueryContext, _response.Value, ordinal: 0, out _)
: default;
if (_response is not { } response)
{
Current = default!;
_hasExecuted = true;
return false;
}

Current = _shaper(_cosmosQueryContext, response, ordinal: 0, out _);

_hasExecuted = true;

return hasNext;
return true;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable

using Microsoft.EntityFrameworkCore.Internal;
using static System.Linq.Expressions.Expression;

Expand Down Expand Up @@ -42,7 +40,7 @@ protected override Expression VisitShapedQuery(ShapedQueryExpression shapedQuery
var shaperBody = shapedQueryExpression.ShaperExpression;

var (paging, maxItemCount, continuationToken, responseContinuationTokenLimitInKb) =
(false, (SqlParameterExpression)null, (SqlParameterExpression)null, (SqlParameterExpression)null);
(false, (SqlParameterExpression?)null, (SqlParameterExpression?)null, (SqlParameterExpression?)null);

// If the query is terminated ToPageAsync(), CosmosQueryableMethodTranslatingExpressionVisitor composed a PagingExpression on top
// of the shaper. We remove that to get the shaper for each actual document being read (as opposed to the page of those documents),
Expand Down Expand Up @@ -108,9 +106,9 @@ protected override Expression VisitShapedQuery(ShapedQueryExpression shapedQuery
Constant(cosmosQueryCompilationContext.PartitionKeyPropertyValues),
standAloneStateManagerConstant,
threadSafetyConstant,
Constant(maxItemCount.Name),
Constant(continuationToken.Name),
Constant(responseContinuationTokenLimitInKb.Name)),
Constant(maxItemCount!.Name),
Constant(continuationToken!.Name),
Constant(responseContinuationTokenLimitInKb!.Name)),

_ => New(
typeof(QueryingEnumerable<>).MakeGenericType(shaperLambda.ReturnType).GetConstructors()[0], cosmosQueryContextConstant,
Expand All @@ -129,7 +127,7 @@ protected override Expression VisitShapedQuery(ShapedQueryExpression shapedQuery
private static PartitionKey GeneratePartitionKey(
IEntityType rootEntityType,
List<Expression> partitionKeyPropertyValues,
IReadOnlyDictionary<string, object> parameterValues)
IReadOnlyDictionary<string, object?> parameterValues)
{
if (partitionKeyPropertyValues.Count == 0)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

namespace Microsoft.EntityFrameworkCore;

#nullable disable

public class BuiltInDataTypesCosmosTest(BuiltInDataTypesCosmosTest.BuiltInDataTypesCosmosFixture fixture)
: BuiltInDataTypesTestBase<BuiltInDataTypesCosmosTest.BuiltInDataTypesCosmosFixture>(fixture)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

namespace Microsoft.EntityFrameworkCore;

#nullable disable

public class ConcurrencyDetectorDisabledCosmosTest(ConcurrencyDetectorDisabledCosmosTest.ConcurrencyDetectorCosmosFixture fixture)
: ConcurrencyDetectorDisabledTestBase<
ConcurrencyDetectorDisabledCosmosTest.ConcurrencyDetectorCosmosFixture>(fixture)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

namespace Microsoft.EntityFrameworkCore;

#nullable disable

public class ConcurrencyDetectorEnabledCosmosTest(ConcurrencyDetectorEnabledCosmosTest.ConcurrencyDetectorCosmosFixture fixture)
: ConcurrencyDetectorEnabledTestBase<
ConcurrencyDetectorEnabledCosmosTest.ConcurrencyDetectorCosmosFixture>(fixture)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
// ReSharper disable UnusedAutoPropertyAccessor.Local
namespace Microsoft.EntityFrameworkCore;

#nullable disable

[ConditionalClass(typeof(CosmosTestEnvironment), nameof(CosmosTestEnvironment.DoesNotUseTokenCredential))]
public class ConfigPatternsCosmosTest(ConfigPatternsCosmosTest.CosmosFixture fixture)
: IClassFixture<ConfigPatternsCosmosTest.CosmosFixture>
{
private const string DatabaseName = "ConfigPatternsCosmos";

private IServiceProvider _serviceProvider;
private IServiceProvider? _serviceProvider;

protected CosmosFixture Fixture { get; } = fixture;

Expand Down Expand Up @@ -167,7 +165,7 @@ public async Task Cosmos_client_instance_is_thread_safe()

private DbContextOptions CreateOptions(
CosmosTestStore testDatabase,
Action<DbContextOptionsBuilder> configure = null,
Action<DbContextOptionsBuilder>? configure = null,
bool useExternalServiceProvider = true)
{
var builder = Fixture.AddOptions(testDatabase.AddProviderOptions(new DbContextOptionsBuilder()))
Expand All @@ -186,7 +184,7 @@ private DbContextOptions CreateOptions(
private class Customer
{
public int Id { get; set; }
public string Name { get; set; }
public string Name { get; set; } = null!;
}

private class CustomerContext(DbContextOptions dbContextOptions) : DbContext(dbContextOptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

namespace Microsoft.EntityFrameworkCore;

#nullable disable

[ConditionalClass(typeof(CosmosTestEnvironment), nameof(CosmosTestEnvironment.DoesNotUseTokenCredential))]
public class ConnectionSpecificationTest
{
Expand All @@ -29,7 +27,8 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseCosmos(_connectionString, _name, b => b.ApplyConfiguration())
.ConfigureWarnings(w => w.Ignore(CoreEventId.ManyServiceProvidersCreatedWarning));

public DbSet<Blog> Blogs { get; set; }
public DbSet<Blog> Blogs
=> Set<Blog>();
}

[Fact]
Expand Down
14 changes: 6 additions & 8 deletions test/EFCore.Cosmos.FunctionalTests/CosmosApiConsistencyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

namespace Microsoft.EntityFrameworkCore;

#nullable disable

public class CosmosApiConsistencyTest(CosmosApiConsistencyTest.CosmosApiConsistencyFixture fixture)
: ApiConsistencyTestBase<CosmosApiConsistencyTest.CosmosApiConsistencyFixture>(fixture)
{
Expand Down Expand Up @@ -51,7 +49,7 @@ public override
typeof(CosmosModelExtensions),
typeof(CosmosModelExtensions),
typeof(CosmosModelBuilderExtensions),
null
null!
)
},
{
Expand All @@ -60,7 +58,7 @@ public override
typeof(CosmosEntityTypeExtensions),
typeof(CosmosEntityTypeExtensions),
typeof(CosmosEntityTypeBuilderExtensions),
null
null!
)
},
{
Expand All @@ -69,16 +67,16 @@ public override
typeof(CosmosPropertyExtensions),
typeof(CosmosPropertyExtensions),
typeof(CosmosPropertyBuilderExtensions),
null
null!
)
},
{
typeof(IReadOnlyComplexProperty), (
typeof(CosmosComplexPropertyExtensions),
null,
null,
null!,
null!,
typeof(CosmosComplexPropertyBuilderExtensions),
null
null!
)
},
};
Expand Down
Loading
Loading