Skip to content

Commit

Permalink
Add query documentation in EF Core
Browse files Browse the repository at this point in the history
Enable warning 1591

Will do relational assembly in other pass hence disabled in that csproj.

Also,
Make EntityMaterializerSource public internal
Make QueryableMethods to be shared internal
Make IParameterValues public internal
  • Loading branch information
smitpatel committed Apr 14, 2020
1 parent 7a30fe7 commit 6c3114c
Show file tree
Hide file tree
Showing 162 changed files with 3,665 additions and 381 deletions.
5 changes: 5 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
<PackageProjectUrl>https://docs.microsoft.com/ef/core/</PackageProjectUrl>
</PropertyGroup>

<!-- HACK: Work around #15093 -->
<PropertyGroup>
<NoWarn>$(NoWarn.Replace(';1591', ''))</NoWarn>
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="**\*.rd.xml" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ public virtual CosmosOptionsExtension WithExecutionStrategyFactory(
/// </summary>
protected virtual CosmosOptionsExtension Clone() => new CosmosOptionsExtension(this);

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual void ApplyServices(IServiceCollection services)
=> services.AddEntityFrameworkCosmos();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ public interface ICosmosSingletonOptions : ISingletonOptions
/// </summary>
string Region { get; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
ConnectionMode? ConnectionMode { get; }
}
}
2 changes: 2 additions & 0 deletions src/EFCore.Cosmos/Metadata/Conventions/StoreKeyConvention.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ public class StoreKeyConvention :
IEntityTypeAnnotationChangedConvention,
IEntityTypeBaseTypeChangedConvention
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public static readonly string IdPropertyName = "id";
public static readonly string JObjectPropertyName = "__jObject";
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member

/// <summary>
/// Creates a new instance of <see cref="StoreKeyConvention" />.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ protected override Expression VisitMember(MemberExpression memberExpression)
}
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression)
{
Check.NotNull(methodCallExpression, nameof(methodCallExpression));
Expand Down
23 changes: 20 additions & 3 deletions src/EFCore.Cosmos/Query/Internal/CosmosQueryCompilationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,32 @@

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public class CosmosQueryCompilationContext : QueryCompilationContext
{
public virtual string PartitionKey { get; internal set; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public CosmosQueryCompilationContext(
[NotNull] QueryCompilationContextDependencies dependencies, bool async)
: base(dependencies, async)
{

}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual string PartitionKey { get; internal set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
/// <para>
/// A factory for creating <see cref="CosmosQueryCompilationContext" /> instances.
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </para>
/// <para>
/// The service lifetime is <see cref="ServiceLifetime.Scoped" />. This means that each
Expand All @@ -23,12 +26,24 @@ public class CosmosQueryCompilationContextFactory : IQueryCompilationContextFact
{
private readonly QueryCompilationContextDependencies _dependencies;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public CosmosQueryCompilationContextFactory([NotNull] QueryCompilationContextDependencies dependencies)
{
Check.NotNull(dependencies, nameof(dependencies));
_dependencies = dependencies;
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual QueryCompilationContext Create(bool async)
=> new CosmosQueryCompilationContext(_dependencies, async);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,34 @@

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public class CosmosQueryMetadataExtractingExpressionVisitor : ExpressionVisitor
{
private readonly CosmosQueryCompilationContext _cosmosQueryCompilationContext;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public CosmosQueryMetadataExtractingExpressionVisitor([NotNull] CosmosQueryCompilationContext cosmosQueryCompilationContext)
{
Check.NotNull(cosmosQueryCompilationContext, nameof(cosmosQueryCompilationContext));
_cosmosQueryCompilationContext = cosmosQueryCompilationContext;
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression)
{
if (methodCallExpression.Method.IsGenericMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,22 @@

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public class CosmosQueryTranslationPreprocessor : QueryTranslationPreprocessor
{

private readonly CosmosQueryCompilationContext _queryCompilationContext;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public CosmosQueryTranslationPreprocessor(
[NotNull] QueryTranslationPreprocessorDependencies dependencies,
[NotNull] CosmosQueryCompilationContext cosmosQueryCompilationContext)
Expand All @@ -20,9 +31,15 @@ public CosmosQueryTranslationPreprocessor(
_queryCompilationContext = cosmosQueryCompilationContext;
}

public override Expression NormalizeQueryableMethodCall(Expression query)
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public override Expression NormalizeQueryableMethod(Expression query)
{
query = base.NormalizeQueryableMethodCall(query);
query = base.NormalizeQueryableMethod(query);

query = new CosmosQueryMetadataExtractingExpressionVisitor(_queryCompilationContext).Visit(query);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
/// <para>
/// A factory for creating <see cref="CosmosQueryTranslationPreprocessor" /> instances.
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </para>
/// <para>
/// The service lifetime is <see cref="ServiceLifetime.Singleton" />. This means a single instance
Expand All @@ -22,13 +25,25 @@ public class CosmosQueryTranslationPreprocessorFactory : IQueryTranslationPrepro
{
private readonly QueryTranslationPreprocessorDependencies _dependencies;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public CosmosQueryTranslationPreprocessorFactory(
[NotNull] QueryTranslationPreprocessorDependencies dependencies)
{
Check.NotNull(dependencies, nameof(dependencies));
_dependencies = dependencies;
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual QueryTranslationPreprocessor Create(QueryCompilationContext queryCompilationContext)
=> new CosmosQueryTranslationPreprocessor(_dependencies, (CosmosQueryCompilationContext)queryCompilationContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public CosmosQueryableMethodTranslatingExpressionVisitor(
[NotNull] ISqlExpressionFactory sqlExpressionFactory,
[NotNull] IMemberTranslatorProvider memberTranslatorProvider,
[NotNull] IMethodCallTranslatorProvider methodCallTranslatorProvider)
: base(dependencies, subquery: false)
: base(dependencies, queryCompilationContext, subquery: false)
{
_model = queryCompilationContext.Model;
_sqlExpressionFactory = sqlExpressionFactory;
Expand All @@ -60,7 +60,7 @@ public CosmosQueryableMethodTranslatingExpressionVisitor(
/// </summary>
protected CosmosQueryableMethodTranslatingExpressionVisitor(
[NotNull] CosmosQueryableMethodTranslatingExpressionVisitor parentVisitor)
: base(parentVisitor.Dependencies, subquery: true)
: base(parentVisitor.Dependencies, parentVisitor.QueryCompilationContext, subquery: true)
{
_model = parentVisitor._model;
_sqlExpressionFactory = parentVisitor._sqlExpressionFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected override Expression VisitShapedQuery(ShapedQueryExpression shapedQuery
shaperBody = new JObjectInjectingExpressionVisitor()
.Visit(shaperBody);
shaperBody = InjectEntityMaterializers(shaperBody);
shaperBody = new CosmosProjectionBindingRemovingExpressionVisitor(selectExpression, jObjectParameter, IsTracking)
shaperBody = new CosmosProjectionBindingRemovingExpressionVisitor(selectExpression, jObjectParameter, QueryCompilationContext.IsTracking)
.Visit(shaperBody);

var shaperLambda = Expression.Lambda(
Expand Down
6 changes: 6 additions & 0 deletions src/EFCore.Cosmos/Query/Internal/SqlFunctionExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
/// </summary>
public class SqlFunctionExpression : SqlExpression
{
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public SqlFunctionExpression(
[NotNull] string name,
[CanBeNull] IEnumerable<SqlExpression> arguments,
Expand Down
6 changes: 6 additions & 0 deletions src/EFCore.Cosmos/Query/Internal/SqlUnaryExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ public SqlUnaryExpression(
/// </summary>
public virtual SqlExpression Operand { get; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
protected override Expression VisitChildren(ExpressionVisitor visitor)
{
Check.NotNull(visitor, nameof(visitor));
Expand Down
8 changes: 7 additions & 1 deletion src/EFCore.Cosmos/Update/Internal/DocumentSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public virtual JObject CreateDocument([NotNull] IUpdateEntry entry, int? ordinal
/// </summary>
public virtual JObject UpdateDocument([NotNull] JObject document, [NotNull] IUpdateEntry entry)
=> UpdateDocument(document, entry, null);

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down Expand Up @@ -286,6 +286,12 @@ private IProperty GetOrdinalKeyProperty(IEntityType entityType)
=> entityType.FindPrimaryKey().Properties.FirstOrDefault(p =>
p.GetJsonPropertyName().Length == 0 && p.IsOrdinalKeyProperty());

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual JObject GetCurrentDocument([NotNull] IUpdateEntry entry)
=> _jObjectProperty != null
? (JObject)(entry.SharedIdentityEntry ?? entry).GetCurrentValue(_jObjectProperty)
Expand Down
Loading

0 comments on commit 6c3114c

Please sign in to comment.