Skip to content

Commit

Permalink
Document some internal constructors
Browse files Browse the repository at this point in the history
Part of #16708
  • Loading branch information
ajcvickers committed Jun 19, 2020
1 parent 1a78b52 commit 263b792
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 22 deletions.
17 changes: 11 additions & 6 deletions src/EFCore.Cosmos/Query/Internal/SqlParameterExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
/// 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>
// Class is sealed because there are no public/protected constructors. Can be unsealed if this is changed.
public sealed class SqlParameterExpression : SqlExpression
{
private readonly ParameterExpression _parameterExpression;

internal SqlParameterExpression(ParameterExpression parameterExpression, CoreTypeMapping typeMapping)
/// <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 SqlParameterExpression([NotNull] ParameterExpression parameterExpression, [CanBeNull] CoreTypeMapping typeMapping)
: base(parameterExpression.Type, typeMapping)
{
_parameterExpression = parameterExpression;
Expand Down Expand Up @@ -78,13 +83,13 @@ protected override void Print(ExpressionPrinter expressionPrinter)
/// </summary>
public override bool Equals(object obj)
=> obj != null
&& (ReferenceEquals(this, obj)
|| obj is SqlParameterExpression sqlParameterExpression
&& Equals(sqlParameterExpression));
&& (ReferenceEquals(this, obj)
|| obj is SqlParameterExpression sqlParameterExpression
&& Equals(sqlParameterExpression));

private bool Equals(SqlParameterExpression sqlParameterExpression)
=> base.Equals(sqlParameterExpression)
&& string.Equals(Name, sqlParameterExpression.Name);
&& string.Equals(Name, sqlParameterExpression.Name);

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Query.SqlExpressions;
using Microsoft.EntityFrameworkCore.Utilities;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Linq;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Utilities;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ namespace Microsoft.EntityFrameworkCore.Query.SqlExpressions
/// An expression that represents a projection in <see cref="SelectExpression"/>.
/// </para>
/// <para>
/// This type is typically used by database providers (and other extensions). It is generally
/// not used in application code.
/// This is a simple wrapper around a <see cref="SqlExpression"/> and an alias.
/// Instances of this type cannot be constructed by application or database provider code. If this is a problem for your
/// application or provider, then please file an issue at https://github.com/dotnet/efcore.
/// </para>
/// </summary>
// Class is sealed because there are no public/protected constructors. Can be unsealed if this is changed.
public sealed class ProjectionExpression : Expression, IPrintableExpression
{
internal ProjectionExpression([NotNull] SqlExpression expression, [NotNull] string alias)
Expand All @@ -41,7 +41,7 @@ internal ProjectionExpression([NotNull] SqlExpression expression, [NotNull] stri
/// <inheritdoc />
public override Type Type => Expression.Type;
/// <inheritdoc />
public sealed override ExpressionType NodeType => ExpressionType.Extension;
public override ExpressionType NodeType => ExpressionType.Extension;

/// <inheritdoc />
protected override Expression VisitChildren(ExpressionVisitor visitor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ namespace Microsoft.EntityFrameworkCore.Query.SqlExpressions
/// An expression that represents a parameter in a SQL tree.
/// </para>
/// <para>
/// This type is typically used by database providers (and other extensions). It is generally
/// not used in application code.
/// This is a simple wrapper around a <see cref="ParameterExpression"/> in the SQL tree.
/// Instances of this type cannot be constructed by application or database provider code. If this is a problem for your
/// application or provider, then please file an issue at https://github.com/dotnet/efcore.
/// </para>
/// </summary>
// Class is sealed because there are no public/protected constructors. Can be unsealed if this is changed.
public sealed class SqlParameterExpression : SqlExpression
{
private readonly ParameterExpression _parameterExpression;
Expand Down
7 changes: 4 additions & 3 deletions src/EFCore.Relational/Query/SqlExpressions/TableExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ namespace Microsoft.EntityFrameworkCore.Query.SqlExpressions
/// An expression that represents a table or view in a SQL tree.
/// </para>
/// <para>
/// This type is typically used by database providers (and other extensions). It is generally
/// not used in application code.
/// This is a simple wrapper around a table and schema name. Instances of this type cannot be constructed by
/// application or database provider code. If this is a problem for your application or provider, then please file
/// an issue at https://github.com/dotnet/efcore.
/// </para>
/// </summary>
// Class is sealed because there are no public/protected constructors. Can be unsealed if this is changed.
public sealed class TableExpression : TableExpressionBase
{
internal TableExpression([NotNull] ITableBase table)
Expand All @@ -44,6 +44,7 @@ protected override void Print(ExpressionPrinter expressionPrinter)
/// The name of the table or view.
/// </summary>
public string Name { get; }

/// <summary>
/// The schema of the table or view.
/// </summary>
Expand Down
5 changes: 3 additions & 2 deletions src/EFCore/DbFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ namespace Microsoft.EntityFrameworkCore
/// Provides CLR methods that get translated to database functions when used in LINQ to Entities queries.
/// The methods on this class are accessed via <see cref="EF.Functions" />.
/// </summary>
// Class is sealed because there are no public/protected constructors. Can be unsealed if this is changed.
public sealed class DbFunctions
{
internal DbFunctions()
private DbFunctions()
{
}

internal static DbFunctions Instance { get; } = new DbFunctions();

#region Hidden System.Object members

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion src/EFCore/EF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public static TProperty Property<TProperty>(
/// Provides CLR methods that get translated to database functions when used in LINQ to Entities queries.
/// Calling these methods in other contexts (e.g. LINQ to Objects) will throw a <see cref="NotSupportedException" />.
/// </summary>
public static DbFunctions Functions { get; } = new DbFunctions();
public static DbFunctions Functions
=> DbFunctions.Instance;
}
}
2 changes: 1 addition & 1 deletion test/EFCore.Tests/DbFunctionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void Like_on_client_throws()
Assert.Equal(
CoreStrings.FunctionOnClient(nameof(DbFunctionsExtensions.Like)),
Assert.Throws<InvalidOperationException>(
() => new DbFunctions().Like("abc", "abc")).Message);
() => EF.Functions.Like("abc", "abc")).Message);
}
}
}

0 comments on commit 263b792

Please sign in to comment.