Skip to content

Commit

Permalink
Rename Scalars to DefaultTypeMapping
Browse files Browse the repository at this point in the history
Part of #24743
  • Loading branch information
AndriySvyryd committed Aug 18, 2021
1 parent ca83774 commit f5a8583
Show file tree
Hide file tree
Showing 21 changed files with 134 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ private string CreateModelBuilder(
namespaces,
variables);

foreach (var typeConfiguration in model.GetScalarTypeConfigurations())
foreach (var typeConfiguration in model.GetTypeMappingConfigurations())
{
Create(typeConfiguration, parameters);
}
Expand Down Expand Up @@ -383,14 +383,14 @@ private string CreateModelBuilder(
}

private void Create(
IScalarTypeConfiguration typeConfiguration,
ITypeMappingConfiguration typeConfiguration,
CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
{
var variableName = _code.Identifier("type", parameters.ScopeVariables, capitalize: false);

var mainBuilder = parameters.MainBuilder;
mainBuilder
.Append("var ").Append(variableName).Append(" = ").Append(parameters.TargetName).AppendLine(".AddScalarTypeConfiguration(")
.Append("var ").Append(variableName).Append(" = ").Append(parameters.TargetName).AppendLine(".AddTypeMappingConfiguration(")
.IncrementIndent()
.Append(_code.Literal(typeConfiguration.ClrType));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Microsoft.EntityFrameworkCore
{
/// <summary>
/// Relational database specific extension methods for <see cref="ScalarConfigurationBuilder" />.
/// Relational database specific extension methods for <see cref="TypeMappingConfigurationBuilder" />.
/// </summary>
public static class ScalarConfigurationBuilderExtensions
{
Expand All @@ -20,14 +20,14 @@ public static class ScalarConfigurationBuilderExtensions
/// <param name="scalarBuilder"> The builder for the scalar being configured. </param>
/// <param name="typeName"> The name of the data type of the column. </param>
/// <returns> The same builder instance so that multiple calls can be chained. </returns>
public static ScalarConfigurationBuilder HaveColumnType(
this ScalarConfigurationBuilder scalarBuilder,
public static TypeMappingConfigurationBuilder HaveColumnType(
this TypeMappingConfigurationBuilder scalarBuilder,
string typeName)
{
Check.NotNull(scalarBuilder, nameof(scalarBuilder));
Check.NotEmpty(typeName, nameof(typeName));

scalarBuilder.HaveAnnotation(RelationalAnnotationNames.ColumnType, typeName);
scalarBuilder.HasAnnotation(RelationalAnnotationNames.ColumnType, typeName);

return scalarBuilder;
}
Expand All @@ -40,24 +40,24 @@ public static ScalarConfigurationBuilder HaveColumnType(
/// <param name="scalarBuilder"> The builder for the scalar being configured. </param>
/// <param name="typeName"> The name of the data type of the column. </param>
/// <returns> The same builder instance so that multiple calls can be chained. </returns>
public static ScalarConfigurationBuilder<TScalar> HaveColumnType<TScalar>(
this ScalarConfigurationBuilder<TScalar> scalarBuilder,
public static TypeMappingConfigurationBuilder<TScalar> HaveColumnType<TScalar>(
this TypeMappingConfigurationBuilder<TScalar> scalarBuilder,
string typeName)
=> (ScalarConfigurationBuilder<TScalar>)HaveColumnType((ScalarConfigurationBuilder)scalarBuilder, typeName);
=> (TypeMappingConfigurationBuilder<TScalar>)HaveColumnType((TypeMappingConfigurationBuilder)scalarBuilder, typeName);

/// <summary>
/// Configures the scalar as capable of storing only fixed-length data, such as strings.
/// </summary>
/// <param name="scalarBuilder"> The builder for the scalar being configured. </param>
/// <param name="fixedLength"> A value indicating whether the scalar is constrained to fixed length values. </param>
/// <returns> The same builder instance so that multiple configuration calls can be chained. </returns>
public static ScalarConfigurationBuilder AreFixedLength(
this ScalarConfigurationBuilder scalarBuilder,
public static TypeMappingConfigurationBuilder AreFixedLength(
this TypeMappingConfigurationBuilder scalarBuilder,
bool fixedLength = true)
{
Check.NotNull(scalarBuilder, nameof(scalarBuilder));

scalarBuilder.HaveAnnotation(RelationalAnnotationNames.IsFixedLength, fixedLength);
scalarBuilder.HasAnnotation(RelationalAnnotationNames.IsFixedLength, fixedLength);

return scalarBuilder;
}
Expand All @@ -69,9 +69,9 @@ public static ScalarConfigurationBuilder AreFixedLength(
/// <param name="scalarBuilder"> The builder for the scalar being configured. </param>
/// <param name="fixedLength"> A value indicating whether the scalar is constrained to fixed length values. </param>
/// <returns> The same builder instance so that multiple configuration calls can be chained. </returns>
public static ScalarConfigurationBuilder<TScalar> AreFixedLength<TScalar>(
this ScalarConfigurationBuilder<TScalar> scalarBuilder,
public static TypeMappingConfigurationBuilder<TScalar> AreFixedLength<TScalar>(
this TypeMappingConfigurationBuilder<TScalar> scalarBuilder,
bool fixedLength = true)
=> (ScalarConfigurationBuilder<TScalar>)AreFixedLength((ScalarConfigurationBuilder)scalarBuilder, fixedLength);
=> (TypeMappingConfigurationBuilder<TScalar>)AreFixedLength((TypeMappingConfigurationBuilder)scalarBuilder, fixedLength);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ protected override CoreTypeMapping FindMapping(in TypeMappingInfo mappingInfo)
public override CoreTypeMapping? FindMapping(Type type, IModel model)
{
type = type.UnwrapNullableType();
var typeConfiguration = model.FindScalarTypeConfiguration(type);
var typeConfiguration = model.FindTypeMappingConfiguration(type);
RelationalTypeMappingInfo mappingInfo;
Type? providerClrType = null;
ValueConverter? customConverter = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public virtual void Generate(IIndex index, CSharpRuntimeAnnotationCodeGeneratorP
}

/// <inheritdoc />
public virtual void Generate(IScalarTypeConfiguration typeConfiguration, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
public virtual void Generate(ITypeMappingConfiguration typeConfiguration, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
{
if (!parameters.IsRuntime)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ public interface ICSharpRuntimeAnnotationCodeGenerator
/// </summary>
/// <param name="typeConfiguration"> The scalar type configuration to which the annotations are applied. </param>
/// <param name="parameters"> Additional parameters used during code generation. </param>
void Generate(IScalarTypeConfiguration typeConfiguration, CSharpRuntimeAnnotationCodeGeneratorParameters parameters);
void Generate(ITypeMappingConfiguration typeConfiguration, CSharpRuntimeAnnotationCodeGeneratorParameters parameters);
}
}
26 changes: 13 additions & 13 deletions src/EFCore/Metadata/Builders/PropertiesConfigurationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public PropertiesConfigurationBuilder(PropertyConfiguration property)
{
Check.NotNull(property, nameof(property));

Property = property;
Configuration = property;
}

/// <summary>
Expand All @@ -43,7 +43,7 @@ public PropertiesConfigurationBuilder(PropertyConfiguration property)
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
[EntityFrameworkInternal]
protected virtual PropertyConfiguration Property { get; }
protected virtual PropertyConfiguration Configuration { get; }

/// <summary>
/// Adds or updates an annotation on the property.
Expand All @@ -55,7 +55,7 @@ public virtual PropertiesConfigurationBuilder HaveAnnotation(string annotation,
{
Check.NotEmpty(annotation, nameof(annotation));

Property[annotation] = value;
Configuration[annotation] = value;

return this;
}
Expand All @@ -68,7 +68,7 @@ public virtual PropertiesConfigurationBuilder HaveAnnotation(string annotation,
/// <returns> The same builder instance so that multiple configuration calls can be chained. </returns>
public virtual PropertiesConfigurationBuilder HaveMaxLength(int maxLength)
{
Property.SetMaxLength(maxLength);
Configuration.SetMaxLength(maxLength);

return this;
}
Expand All @@ -81,8 +81,8 @@ public virtual PropertiesConfigurationBuilder HaveMaxLength(int maxLength)
/// <returns> The same builder instance so that multiple configuration calls can be chained. </returns>
public virtual PropertiesConfigurationBuilder HavePrecision(int precision, int scale)
{
Property.SetPrecision(precision);
Property.SetScale(scale);
Configuration.SetPrecision(precision);
Configuration.SetScale(scale);

return this;
}
Expand All @@ -96,7 +96,7 @@ public virtual PropertiesConfigurationBuilder HavePrecision(int precision, int s
/// <returns> The same builder instance so that multiple configuration calls can be chained. </returns>
public virtual PropertiesConfigurationBuilder HavePrecision(int precision)
{
Property.SetPrecision(precision);
Configuration.SetPrecision(precision);

return this;
}
Expand All @@ -109,7 +109,7 @@ public virtual PropertiesConfigurationBuilder HavePrecision(int precision)
/// <returns> The same builder instance so that multiple configuration calls can be chained. </returns>
public virtual PropertiesConfigurationBuilder AreUnicode(bool unicode = true)
{
Property.SetIsUnicode(unicode);
Configuration.SetIsUnicode(unicode);

return this;
}
Expand All @@ -135,11 +135,11 @@ public virtual PropertiesConfigurationBuilder HaveConversion(Type conversionType

if (typeof(ValueConverter).IsAssignableFrom(conversionType))
{
Property.SetValueConverter(conversionType);
Configuration.SetValueConverter(conversionType);
}
else
{
Property.SetProviderClrType(conversionType);
Configuration.SetProviderClrType(conversionType);
}

return this;
Expand Down Expand Up @@ -169,14 +169,14 @@ public virtual PropertiesConfigurationBuilder HaveConversion(Type conversionType

if (typeof(ValueConverter).IsAssignableFrom(conversionType))
{
Property.SetValueConverter(conversionType);
Configuration.SetValueConverter(conversionType);
}
else
{
Property.SetProviderClrType(conversionType);
Configuration.SetProviderClrType(conversionType);
}

Property.SetValueComparer(comparerType);
Configuration.SetValueComparer(comparerType);

return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Builders
/// and it is not designed to be directly constructed in your application code.
/// </para>
/// </summary>
public class ScalarConfigurationBuilder
public class TypeMappingConfigurationBuilder
{
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand All @@ -27,11 +27,11 @@ public class ScalarConfigurationBuilder
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
[EntityFrameworkInternal]
public ScalarConfigurationBuilder(PropertyConfiguration scalar)
public TypeMappingConfigurationBuilder(PropertyConfiguration scalar)
{
Check.NotNull(scalar, nameof(scalar));

Scalar = scalar;
Configuration = scalar;
}

/// <summary>
Expand All @@ -41,19 +41,19 @@ public ScalarConfigurationBuilder(PropertyConfiguration scalar)
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
[EntityFrameworkInternal]
protected virtual PropertyConfiguration Scalar { get; }
protected virtual PropertyConfiguration Configuration { get; }

/// <summary>
/// Adds or updates an annotation on the property.
/// </summary>
/// <param name="annotation"> The key of the annotation to be added or updated. </param>
/// <param name="value"> The value to be stored in the annotation. </param>
/// <returns> The same builder instance so that multiple configuration calls can be chained. </returns>
public virtual ScalarConfigurationBuilder HaveAnnotation(string annotation, object value)
public virtual TypeMappingConfigurationBuilder HasAnnotation(string annotation, object value)
{
Check.NotEmpty(annotation, nameof(annotation));

Scalar[annotation] = value;
Configuration[annotation] = value;

return this;
}
Expand All @@ -64,9 +64,9 @@ public virtual ScalarConfigurationBuilder HaveAnnotation(string annotation, obje
/// </summary>
/// <param name="maxLength"> The maximum length of data allowed in the property. </param>
/// <returns> The same builder instance so that multiple configuration calls can be chained. </returns>
public virtual ScalarConfigurationBuilder HaveMaxLength(int maxLength)
public virtual TypeMappingConfigurationBuilder HasMaxLength(int maxLength)
{
Scalar.SetMaxLength(maxLength);
Configuration.SetMaxLength(maxLength);

return this;
}
Expand All @@ -77,10 +77,10 @@ public virtual ScalarConfigurationBuilder HaveMaxLength(int maxLength)
/// <param name="precision"> The precision of the property. </param>
/// <param name="scale"> The scale of the property. </param>
/// <returns> The same builder instance so that multiple configuration calls can be chained. </returns>
public virtual ScalarConfigurationBuilder HavePrecision(int precision, int scale)
public virtual TypeMappingConfigurationBuilder HasPrecision(int precision, int scale)
{
Scalar.SetPrecision(precision);
Scalar.SetScale(scale);
Configuration.SetPrecision(precision);
Configuration.SetScale(scale);

return this;
}
Expand All @@ -92,9 +92,9 @@ public virtual ScalarConfigurationBuilder HavePrecision(int precision, int scale
/// </summary>
/// <param name="precision"> The precision of the property. </param>
/// <returns> The same builder instance so that multiple configuration calls can be chained. </returns>
public virtual ScalarConfigurationBuilder HavePrecision(int precision)
public virtual TypeMappingConfigurationBuilder HasPrecision(int precision)
{
Scalar.SetPrecision(precision);
Configuration.SetPrecision(precision);

return this;
}
Expand All @@ -105,9 +105,9 @@ public virtual ScalarConfigurationBuilder HavePrecision(int precision)
/// </summary>
/// <param name="unicode"> A value indicating whether the property can contain unicode characters. </param>
/// <returns> The same builder instance so that multiple configuration calls can be chained. </returns>
public virtual ScalarConfigurationBuilder AreUnicode(bool unicode = true)
public virtual TypeMappingConfigurationBuilder IsUnicode(bool unicode = true)
{
Scalar.SetIsUnicode(unicode);
Configuration.SetIsUnicode(unicode);

return this;
}
Expand All @@ -118,26 +118,26 @@ public virtual ScalarConfigurationBuilder AreUnicode(bool unicode = true)
/// </summary>
/// <typeparam name="TConversion"> The type to convert to and from or a type that derives from <see cref="ValueConverter"/>. </typeparam>
/// <returns> The same builder instance so that multiple configuration calls can be chained. </returns>
public virtual ScalarConfigurationBuilder HaveConversion<TConversion>()
=> HaveConversion(typeof(TConversion));
public virtual TypeMappingConfigurationBuilder HasConversion<TConversion>()
=> HasConversion(typeof(TConversion));

/// <summary>
/// Configures the property so that the property value is converted before
/// writing to the database and converted back when reading from the database.
/// </summary>
/// <param name="conversionType"> The type to convert to and from or a type that derives from <see cref="ValueConverter"/>. </param>
/// <returns> The same builder instance so that multiple configuration calls can be chained. </returns>
public virtual ScalarConfigurationBuilder HaveConversion(Type conversionType)
public virtual TypeMappingConfigurationBuilder HasConversion(Type conversionType)
{
Check.NotNull(conversionType, nameof(conversionType));

if (typeof(ValueConverter).IsAssignableFrom(conversionType))
{
Scalar.SetValueConverter(conversionType);
Configuration.SetValueConverter(conversionType);
}
else
{
Scalar.SetProviderClrType(conversionType);
Configuration.SetProviderClrType(conversionType);
}

return this;
Expand Down
Loading

0 comments on commit f5a8583

Please sign in to comment.