Skip to content

Commit

Permalink
Some missed NotNulls.
Browse files Browse the repository at this point in the history
  • Loading branch information
lajones committed Jun 4, 2020
1 parent 546547d commit 94be95c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 29 deletions.
28 changes: 14 additions & 14 deletions src/EFCore.Relational/Extensions/RelationalIndexExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,31 @@ namespace Microsoft.EntityFrameworkCore
public static class RelationalIndexExtensions
{
/// <summary>
/// Returns the name of the index on the database.
/// Returns the name of the index in the database.
/// </summary>
/// <param name="index"> The index. </param>
/// <returns> The name of the index on the database. </returns>
/// <returns> The name of the index in the database. </returns>
public static string GetDatabaseName([NotNull] this IIndex index)
=> (string)index[RelationalAnnotationNames.Name]
?? index.Name
?? index.GetDefaultDatabaseName();

/// <summary>
/// Returns the name of the index on the database.
/// Returns the name of the index in the database.
/// </summary>
/// <param name="index"> The index. </param>
/// <returns> The name of the index on the database. </returns>
/// <returns> The name of the index in the database. </returns>
[Obsolete("Use GetDatabaseName() instead")]
public static string GetName([NotNull] this IIndex index)
=> GetDatabaseName(index);

/// <summary>
/// Returns the name of the index on the database.
/// Returns the name of the index in the database.
/// </summary>
/// <param name="index"> The index. </param>
/// <param name="tableName"> The table name. </param>
/// <param name="schema"> The schema. </param>
/// <returns> The name of the index on the database. </returns>
/// <returns> The name of the index in the database. </returns>
public static string GetDatabaseName(
[NotNull] this IIndex index,
[NotNull] string tableName,
Expand Down Expand Up @@ -127,7 +127,7 @@ public static string GetDefaultDatabaseName(
}

/// <summary>
/// Sets the name of the index on the database.
/// Sets the name of the index in the database.
/// </summary>
/// <param name="index"> The index. </param>
/// <param name="name"> The value to set. </param>
Expand All @@ -139,7 +139,7 @@ public static void SetDatabaseName([NotNull] this IMutableIndex index, [CanBeNul
}

/// <summary>
/// Sets the name of the index on the database.
/// Sets the name of the index in the database.
/// </summary>
/// <param name="index"> The index. </param>
/// <param name="name"> The value to set. </param>
Expand All @@ -148,7 +148,7 @@ public static void SetName([NotNull] this IMutableIndex index, [CanBeNull] strin
=> SetDatabaseName(index, name);

/// <summary>
/// Sets the name of the index on the database.
/// Sets the name of the index in the database.
/// </summary>
/// <param name="index"> The index. </param>
/// <param name="name"> The value to set. </param>
Expand All @@ -165,7 +165,7 @@ public static string SetDatabaseName([NotNull] this IConventionIndex index, [Can
}

/// <summary>
/// Sets the name of the index on the database.
/// Sets the name of the index in the database.
/// </summary>
/// <param name="index"> The index. </param>
/// <param name="name"> The value to set. </param>
Expand All @@ -176,18 +176,18 @@ public static string SetName([NotNull] this IConventionIndex index, [CanBeNull]
=> SetDatabaseName(index, name, fromDataAnnotation);

/// <summary>
/// Gets the <see cref="ConfigurationSource" /> for the name of the index on the database.
/// Gets the <see cref="ConfigurationSource" /> for the name of the index in the database.
/// </summary>
/// <param name="index"> The index. </param>
/// <returns> The <see cref="ConfigurationSource" /> for the name of the index on the database. </returns>
/// <returns> The <see cref="ConfigurationSource" /> for the name of the index in the database. </returns>
public static ConfigurationSource? GetDatabaseNameConfigurationSource([NotNull] this IConventionIndex index)
=> index.FindAnnotation(RelationalAnnotationNames.Name)?.GetConfigurationSource();

/// <summary>
/// Gets the <see cref="ConfigurationSource" /> for the name of the index on the database.
/// Gets the <see cref="ConfigurationSource" /> for the name of the index in the database.
/// </summary>
/// <param name="index"> The index. </param>
/// <returns> The <see cref="ConfigurationSource" /> for the name of the index on the database. </returns>
/// <returns> The <see cref="ConfigurationSource" /> for the name of the index in the database. </returns>
[Obsolete("Use GetDatabaseNameConfigurationSource() instead.")]
public static ConfigurationSource? GetNameConfigurationSource([NotNull] this IConventionIndex index)
=> GetDatabaseNameConfigurationSource(index);
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore/Metadata/IConventionEntityType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ IConventionIndex AddIndex(
/// <returns> The newly created index. </returns>
IConventionIndex AddIndex(
[NotNull] IReadOnlyList<IConventionProperty> properties,
[CanBeNull] string name,
[NotNull] string name,
bool fromDataAnnotation = false);

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore/Metadata/Internal/EntityType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1860,7 +1860,7 @@ public virtual Index AddIndex(
/// </summary>
public virtual Index AddIndex(
[NotNull] Property property,
[CanBeNull] string name,
[NotNull] string name,
ConfigurationSource configurationSource)
=> AddIndex(
new[] { property }, name, configurationSource);
Expand Down
28 changes: 15 additions & 13 deletions src/EFCore/Metadata/Internal/Index.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,16 @@ public Index(
[NotNull] IReadOnlyList<Property> properties,
[NotNull] EntityType declaringEntityType,
ConfigurationSource configurationSource)
: this(properties, null, declaringEntityType, configurationSource)
{
Check.NotEmpty(properties, nameof(properties));
Check.HasNoNulls(properties, nameof(properties));
Check.NotNull(declaringEntityType, nameof(declaringEntityType));

Properties = properties;
DeclaringEntityType = declaringEntityType;
_configurationSource = configurationSource;

Builder = new InternalIndexBuilder(this, declaringEntityType.Model.Builder);
}

/// <summary>
Expand All @@ -51,21 +59,15 @@ public Index(
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public Index(
[NotNull] IReadOnlyList<Property> properties,
[CanBeNull] string name,
[NotNull] EntityType declaringEntityType,
ConfigurationSource configurationSource)
[NotNull] IReadOnlyList<Property> properties,
[NotNull] string name,
[NotNull] EntityType declaringEntityType,
ConfigurationSource configurationSource)
: this(properties, declaringEntityType, configurationSource)
{
Check.NotEmpty(properties, nameof(properties));
Check.HasNoNulls(properties, nameof(properties));
Check.NotNull(declaringEntityType, nameof(declaringEntityType));
Check.NotEmpty(name, nameof(name));

Properties = properties;
Name = name;
DeclaringEntityType = declaringEntityType;
_configurationSource = configurationSource;

Builder = new InternalIndexBuilder(this, declaringEntityType.Model.Builder);
}

/// <summary>
Expand Down

0 comments on commit 94be95c

Please sign in to comment.