Skip to content

Commit

Permalink
More nullability annotations (#24309)
Browse files Browse the repository at this point in the history
Update pipeline, value generation, and many additional bits and pieces.
  • Loading branch information
roji authored Mar 5, 2021
1 parent 3f5dc2c commit 0f61aac
Show file tree
Hide file tree
Showing 161 changed files with 964 additions and 690 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private static string ExecutingSqlQuery(EventDefinitionBase definition, EventDat
public static void ExecutingReadItem(
[NotNull] this IDiagnosticsLogger<DbLoggerCategory.Database.Command> diagnostics,
[NotNull] string containerId,
[CanBeNull] string partitionKey,
[CanBeNull] string? partitionKey,
[NotNull] string resourceId)
{
var definition = CosmosResources.LogExecutingReadItem(diagnostics);
Expand Down
1 change: 1 addition & 0 deletions src/EFCore.Cosmos/EFCore.Cosmos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<RootNamespace>Microsoft.EntityFrameworkCore.Cosmos</RootNamespace>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>$(PackageTags);CosmosDb;SQL API</PackageTags>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
using Microsoft.EntityFrameworkCore.Utilities;
using Microsoft.Extensions.DependencyInjection;

#nullable enable

// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore
{
Expand Down Expand Up @@ -55,8 +57,6 @@ private static TService GetService<TService>(IInfrastructure<IServiceProvider> d
/// <param name="database"> The facade from <see cref="DbContext.Database" />. </param>
/// <returns> <see langword="true" /> if the Cosmos provider is being used. </returns>
public static bool IsCosmos([NotNull] this DatabaseFacade database)
=> database.ProviderName.Equals(
typeof(CosmosOptionsExtension).Assembly.GetName().Name,
StringComparison.Ordinal);
=> database.ProviderName == typeof(CosmosOptionsExtension).Assembly.GetName().Name;
}
}
10 changes: 6 additions & 4 deletions src/EFCore.Cosmos/Extensions/CosmosDbContextOptionsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable enable

// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore
{
Expand All @@ -30,7 +32,7 @@ public static DbContextOptionsBuilder<TContext> UseCosmos<TContext>(
[NotNull] string accountEndpoint,
[NotNull] string accountKey,
[NotNull] string databaseName,
[CanBeNull] Action<CosmosDbContextOptionsBuilder> cosmosOptionsAction = null)
[CanBeNull] Action<CosmosDbContextOptionsBuilder>? cosmosOptionsAction = null)
where TContext : DbContext
=> (DbContextOptionsBuilder<TContext>)UseCosmos(
(DbContextOptionsBuilder)optionsBuilder,
Expand All @@ -53,7 +55,7 @@ public static DbContextOptionsBuilder UseCosmos(
[NotNull] string accountEndpoint,
[NotNull] string accountKey,
[NotNull] string databaseName,
[CanBeNull] Action<CosmosDbContextOptionsBuilder> cosmosOptionsAction = null)
[CanBeNull] Action<CosmosDbContextOptionsBuilder>? cosmosOptionsAction = null)
{
Check.NotNull(optionsBuilder, nameof(optionsBuilder));
Check.NotNull(accountEndpoint, nameof(accountEndpoint));
Expand Down Expand Up @@ -88,7 +90,7 @@ public static DbContextOptionsBuilder<TContext> UseCosmos<TContext>(
[NotNull] this DbContextOptionsBuilder<TContext> optionsBuilder,
[NotNull] string connectionString,
[NotNull] string databaseName,
[CanBeNull] Action<CosmosDbContextOptionsBuilder> cosmosOptionsAction = null)
[CanBeNull] Action<CosmosDbContextOptionsBuilder>? cosmosOptionsAction = null)
where TContext : DbContext
=> (DbContextOptionsBuilder<TContext>)UseCosmos(
(DbContextOptionsBuilder)optionsBuilder,
Expand All @@ -108,7 +110,7 @@ public static DbContextOptionsBuilder UseCosmos(
[NotNull] this DbContextOptionsBuilder optionsBuilder,
[NotNull] string connectionString,
[NotNull] string databaseName,
[CanBeNull] Action<CosmosDbContextOptionsBuilder> cosmosOptionsAction = null)
[CanBeNull] Action<CosmosDbContextOptionsBuilder>? cosmosOptionsAction = null)
{
Check.NotNull(optionsBuilder, nameof(optionsBuilder));
Check.NotNull(connectionString, nameof(connectionString));
Expand Down
4 changes: 3 additions & 1 deletion src/EFCore.Cosmos/Extensions/CosmosEntityTypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ public static void SetContainer(
?? GetDefaultContainingPropertyName(entityType);

private static string? GetDefaultContainingPropertyName(IReadOnlyEntityType entityType)
=> entityType.FindOwnership()?.PrincipalToDependent!.Name;
=> entityType.FindOwnership() is IReadOnlyForeignKey ownership
? ownership.PrincipalToDependent!.Name
: null;

/// <summary>
/// Sets the name of the parent property to which the entity type is mapped.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
using Microsoft.EntityFrameworkCore.Utilities;
using Microsoft.EntityFrameworkCore.ValueGeneration;

#nullable enable

// ReSharper disable once CheckNamespace
namespace Microsoft.Extensions.DependencyInjection
{
Expand Down Expand Up @@ -63,7 +65,7 @@ public static IServiceCollection AddEntityFrameworkCosmos([NotNull] this IServic
// New Query pipeline
.TryAdd<IQueryableMethodTranslatingExpressionVisitorFactory, CosmosQueryableMethodTranslatingExpressionVisitorFactory>()
.TryAdd<IShapedQueryCompilingExpressionVisitorFactory, CosmosShapedQueryCompilingExpressionVisitorFactory>()
.TryAdd<ISingletonOptions, ICosmosSingletonOptions>(p => p.GetService<ICosmosSingletonOptions>())
.TryAdd<ISingletonOptions, ICosmosSingletonOptions>(p => p.GetRequiredService<ICosmosSingletonOptions>())
.TryAdd<IQueryTranslationPreprocessorFactory, CosmosQueryTranslationPreprocessorFactory>()
.TryAdd<IQueryCompilationContextFactory, CosmosQueryCompilationContextFactory>()
.TryAdd<IQueryTranslationPostprocessorFactory, CosmosQueryTranslationPostprocessorFactory>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Query;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
public partial class CosmosShapedQueryCompilingExpressionVisitor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
using Microsoft.EntityFrameworkCore.Utilities;
using Newtonsoft.Json.Linq;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
public partial class CosmosShapedQueryCompilingExpressionVisitor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Query;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
public partial class CosmosShapedQueryCompilingExpressionVisitor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore.Storage;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
public partial class CosmosShapedQueryCompilingExpressionVisitor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Microsoft.EntityFrameworkCore.Utilities;
using Newtonsoft.Json.Linq;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
public partial class CosmosShapedQueryCompilingExpressionVisitor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
using Microsoft.EntityFrameworkCore.Query;
using Newtonsoft.Json.Linq;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
using Microsoft.EntityFrameworkCore.Query;
using Newtonsoft.Json.Linq;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using Microsoft.EntityFrameworkCore.Utilities;
using Newtonsoft.Json.Linq;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/EFCore.Cosmos/Query/Internal/IAccessExpression.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/EFCore.Cosmos/Query/Internal/ISqlExpressionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/EFCore.Cosmos/Query/Internal/KeyAccessExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/EFCore.Cosmos/Query/Internal/ObjectAccessExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/EFCore.Cosmos/Query/Internal/ProjectionExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/EFCore.Cosmos/Query/Internal/QuerySqlGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/EFCore.Cosmos/Query/Internal/RandomTranslator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/EFCore.Cosmos/Query/Internal/ReadItemExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/EFCore.Cosmos/Query/Internal/RootReferenceExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/EFCore.Cosmos/Query/Internal/SelectExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/EFCore.Cosmos/Query/Internal/SqlExpressionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Storage;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
4 changes: 3 additions & 1 deletion src/EFCore.Cosmos/Storage/Internal/ByteArrayConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.Collections.Generic;
using Newtonsoft.Json;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal
{
/// <summary>
Expand All @@ -23,7 +25,7 @@ public class ByteArrayConverter : JsonConverter
/// </summary>
public override void WriteJson(
JsonWriter writer,
object value,
object? value,
JsonSerializer serializer)
{
if (value == null)
Expand Down
Loading

0 comments on commit 0f61aac

Please sign in to comment.