Skip to content

Commit

Permalink
Make AnnotatableBuilder public
Browse files Browse the repository at this point in the history
Rename InternalRelationshipBuilder to InternalForeignKeyBuilder
  • Loading branch information
AndriySvyryd committed Mar 28, 2020
1 parent 8771406 commit 9541bd6
Show file tree
Hide file tree
Showing 48 changed files with 450 additions and 568 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Diagnostics;
Expand Down
4 changes: 0 additions & 4 deletions src/EFCore.Relational/Metadata/Builders/DbFunctionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ IConventionDbFunctionBuilder IInfrastructure<IConventionDbFunctionBuilder>.Insta
/// <summary>
/// The function being configured.
/// </summary>
#pragma warning disable EF1001 // Internal EF Core API usage.
public virtual IMutableDbFunction Metadata => Builder.Metadata;
#pragma warning restore EF1001 // Internal EF Core API usage.

/// <summary>
/// Sets the name of the database function.
Expand Down Expand Up @@ -110,9 +108,7 @@ public virtual DbFunctionBuilder HasTranslation([NotNull] Func<IReadOnlyCollecti
/// <param name="name"> The parameter name. </param>
/// <returns> The builder to use for further parameter configuration. </returns>
public virtual DbFunctionParameterBuilder HasParameter([NotNull] string name)
#pragma warning disable EF1001 // Internal EF Core API usage.
=> new DbFunctionParameterBuilder(Builder.HasParameter(name, ConfigurationSource.Explicit).Metadata);
#pragma warning restore EF1001 // Internal EF Core API usage.

#region Hidden System.Object members

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Utilities;

namespace Microsoft.EntityFrameworkCore.Metadata.Builders
Expand Down Expand Up @@ -48,9 +47,7 @@ IConventionDbFunctionParameterBuilder IInfrastructure<IConventionDbFunctionParam
/// <summary>
/// The function parameter metadata that is being built.
/// </summary>
#pragma warning disable EF1001 // Internal EF Core API usage.
public virtual IMutableDbFunctionParameter Metadata => Builder.Metadata;
#pragma warning restore EF1001 // Internal EF Core API usage.

/// <summary>
/// Sets the store type of the function parameter in the database.
Expand Down
4 changes: 0 additions & 4 deletions src/EFCore.Relational/Metadata/Builders/SequenceBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,10 +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.

using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
Expand Down Expand Up @@ -40,9 +38,7 @@ IConventionSequenceBuilder IInfrastructure<IConventionSequenceBuilder>.Instance
/// <summary>
/// The sequence.
/// </summary>
#pragma warning disable EF1001 // Internal EF Core API usage.
public virtual IMutableSequence Metadata => Builder.Metadata;
#pragma warning restore EF1001 // Internal EF Core API usage.

/// <summary>
/// Sets the <see cref="ISequence" /> to increment by the given amount when generating each next value.
Expand Down
10 changes: 5 additions & 5 deletions src/EFCore.Relational/Metadata/IConventionDbFunctionParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Microsoft.EntityFrameworkCore.Metadata
{
/// <summary>
/// Represents a by-convention database function parameter in an <see cref="IConventionDbFunction" />.
/// Represents a <see cref="IConventionDbFunction" /> parameter.
/// </summary>
public interface IConventionDbFunctionParameter : IConventionAnnotatable, IDbFunctionParameter
{
Expand All @@ -18,7 +18,7 @@ public interface IConventionDbFunctionParameter : IConventionAnnotatable, IDbFun
new IConventionDbFunction Function { get; }

/// <summary>
/// The <see cref="IConventionDbFunctionParameterBuilder" /> for building a by-convention function parameter.
/// The <see cref="IConventionDbFunctionParameterBuilder" /> for configuring this function parameter.
/// </summary>
new IConventionDbFunctionParameterBuilder Builder { get; }

Expand All @@ -29,9 +29,9 @@ public interface IConventionDbFunctionParameter : IConventionAnnotatable, IDbFun
ConfigurationSource GetConfigurationSource();

/// <summary>
/// Sets the store type of the parameter in the database.
/// Sets the store type of the parameter.
/// </summary>
/// <param name="storeType"> The store type of the parameter in the database. </param>
/// <param name="storeType"> The store type of the parameter. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
string SetStoreType([CanBeNull] string storeType, bool fromDataAnnotation = false);

Expand All @@ -42,7 +42,7 @@ public interface IConventionDbFunctionParameter : IConventionAnnotatable, IDbFun
ConfigurationSource? GetStoreTypeConfigurationSource();

/// <summary>
/// Sets the type mapping of the parameter in the database.
/// Sets the type mapping of the parameter.
/// </summary>
/// <param name="typeMapping"> The type mapping of the parameter in the database. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Relational/Metadata/IDbFunctionParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Microsoft.EntityFrameworkCore.Metadata
{
/// <summary>
/// Represents a database function parameter in an <see cref="IDbFunction" />.
/// Represents a <see cref="IDbFunction" /> parameter in.
/// </summary>
public interface IDbFunctionParameter : IAnnotatable
{
Expand Down
4 changes: 2 additions & 2 deletions src/EFCore.Relational/Metadata/IMutableDbFunctionParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Microsoft.EntityFrameworkCore.Metadata
{
/// <summary>
/// Represents a mutable database function parameter in an <see cref="IMutableDbFunction" />.
/// Represents a <see cref="IMutableDbFunction" /> parameter.
/// </summary>
public interface IMutableDbFunctionParameter : IMutableAnnotatable, IDbFunctionParameter
{
Expand All @@ -17,7 +17,7 @@ public interface IMutableDbFunctionParameter : IMutableAnnotatable, IDbFunctionP
new IMutableDbFunction Function { get; }

/// <summary>
/// Gets or sets the store (database) type of this parameter.
/// Gets or sets the store type of this parameter.
/// </summary>
new string StoreType { get; [param: CanBeNull] set; }

Expand Down
6 changes: 3 additions & 3 deletions src/EFCore.Relational/Metadata/Internal/DbFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public DbFunction(
[NotNull] IMutableModel model,
ConfigurationSource configurationSource)
{
Check.NotEmpty(name, nameof(name));

if (returnType == null
|| returnType == typeof(void))
{
Expand All @@ -106,9 +108,7 @@ public DbFunction(
ReturnType = returnType;
Model = model;
_configurationSource = configurationSource;
#pragma warning disable EF1001 // Internal EF Core API usage.
Builder = new InternalDbFunctionBuilder(this, ((Model)model).Builder.ModelBuilder);
#pragma warning restore EF1001 // Internal EF Core API usage.
Builder = new InternalDbFunctionBuilder(this, ((IConventionModel)model).Builder);
_parameters = parameters == null
? new List<DbFunctionParameter>()
: parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ public DbFunctionParameter(
Name = name;
Function = function;
ClrType = clrType;
#pragma warning disable EF1001 // Internal EF Core API usage.
Builder = new InternalDbFunctionParameterBuilder(this, function.Builder.ModelBuilder);
#pragma warning restore EF1001 // Internal EF Core API usage.
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Query.SqlExpressions;
Expand All @@ -20,17 +20,15 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Builders
/// 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>
#pragma warning disable EF1001 // Internal EF Core API usage.
public class InternalDbFunctionBuilder : InternalModelItemBuilder<DbFunction>, IConventionDbFunctionBuilder
#pragma warning restore EF1001 // Internal EF Core API usage.
public class InternalDbFunctionBuilder : AnnotatableBuilder<DbFunction, IConventionModelBuilder>, IConventionDbFunctionBuilder
{
/// <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 InternalDbFunctionBuilder([NotNull] DbFunction function, [NotNull] InternalModelBuilder modelBuilder)
public InternalDbFunctionBuilder([NotNull] DbFunction function, [NotNull] IConventionModelBuilder modelBuilder)
: base(function, modelBuilder)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Builders
/// and it is not designed to be directly constructed in your application code.
/// </para>
/// </summary>
#pragma warning disable EF1001 // Internal EF Core API usage.
public class InternalDbFunctionParameterBuilder : InternalModelItemBuilder<DbFunctionParameter>, IConventionDbFunctionParameterBuilder
#pragma warning restore EF1001 // Internal EF Core API usage.
public class InternalDbFunctionParameterBuilder : AnnotatableBuilder<DbFunctionParameter, IConventionModelBuilder>, IConventionDbFunctionParameterBuilder
{
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand All @@ -29,7 +27,7 @@ public class InternalDbFunctionParameterBuilder : InternalModelItemBuilder<DbFun
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
[EntityFrameworkInternal]
public InternalDbFunctionParameterBuilder([NotNull] DbFunctionParameter parameter, [NotNull] InternalModelBuilder modelBuilder)
public InternalDbFunctionParameterBuilder([NotNull] DbFunctionParameter parameter, [NotNull] IConventionModelBuilder modelBuilder)
: base(parameter, modelBuilder)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Diagnostics;
using System.Linq;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata.Internal;

namespace Microsoft.EntityFrameworkCore.Metadata.Builders
Expand All @@ -15,17 +16,15 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Builders
/// 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>
#pragma warning disable EF1001 // Internal EF Core API usage.
public class InternalSequenceBuilder : InternalModelItemBuilder<Sequence>, IConventionSequenceBuilder
#pragma warning restore EF1001 // Internal EF Core API usage.
public class InternalSequenceBuilder : AnnotatableBuilder<Sequence, IConventionModelBuilder>, IConventionSequenceBuilder
{
/// <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 InternalSequenceBuilder([NotNull] Sequence sequence, [NotNull] InternalModelBuilder modelBuilder)
public InternalSequenceBuilder([NotNull] Sequence sequence, [NotNull] IConventionModelBuilder modelBuilder)
: base(sequence, modelBuilder)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -912,9 +912,7 @@ private static string GetDefiningNavigationName(IEntityType entityType)
return entityType.DefiningNavigationName;
}

#pragma warning disable EF1001 // Internal EF Core API usage.
var primaryKey = entityType.FindDeclaredPrimaryKey();
#pragma warning restore EF1001 // Internal EF Core API usage.
var primaryKey = entityType.BaseType == null ? entityType.FindPrimaryKey() : null;
if (primaryKey != null)
{
var definingForeignKey = entityType
Expand Down Expand Up @@ -1842,9 +1840,8 @@ protected virtual void DiffData(

var sourceValue = sourceEntry.GetCurrentValue(sourceProperty);
var targetValue = entry.GetCurrentValue(targetProperty);
var comparer = targetProperty.GetValueComparer(fallback: false)
?? sourceProperty.GetValueComparer(fallback: false)
?? targetProperty.FindTypeMapping()?.Comparer ?? sourceProperty.FindTypeMapping()?.Comparer;
var comparer = targetProperty.GetValueComparer()
?? sourceProperty.GetValueComparer();

var modelValuesChanged
= sourceProperty.ClrType.UnwrapNullableType() == targetProperty.ClrType.UnwrapNullableType()
Expand Down
Loading

0 comments on commit 9541bd6

Please sign in to comment.