Skip to content

Commit

Permalink
Make ToDebugString methods public and DebugViews easily obtainable
Browse files Browse the repository at this point in the history
Part of #20409
  • Loading branch information
ajcvickers committed Apr 18, 2020
1 parent 0471f9b commit bd625fb
Show file tree
Hide file tree
Showing 44 changed files with 1,382 additions and 1,143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,36 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;

namespace Microsoft.EntityFrameworkCore.Metadata.Internal
namespace Microsoft.EntityFrameworkCore.Metadata
{
/// <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.
/// Extension methods for <see cref="ICheckConstraint" />.
/// </summary>
public static class CheckConstraintExtensions
{
/// <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.
/// <para>
/// Creates a human-readable representation of the given metadata.
/// </para>
/// <para>
/// Warning: Do not rely on the format of the returned string.
/// It is designed for debugging only and may change arbitrarily between releases.
/// </para>
/// </summary>
/// <param name="constraint"> The metadata item. </param>
/// <param name="options"> Options for generating the string. </param>
/// <param name="indent"> The number of indent spaces to use before each new line. </param>
/// <returns> A human-readable representation. </returns>
public static string ToDebugString(
[NotNull] this ICheckConstraint constraint,
MetadataDebugStringOptions options,
[NotNull] string indent = "")
int indent = 0)
{
var builder = new StringBuilder();
var indentString = new string(' ', indent);

builder
.Append(indent)
.Append(indentString)
.Append("Check: ");

builder.Append(constraint.Name)
Expand All @@ -41,7 +46,7 @@ public static string ToDebugString(
{
if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
{
builder.Append(constraint.AnnotationsToDebugString(indent: indent + " "));
builder.Append(constraint.AnnotationsToDebugString(indent: indent + 2));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,35 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;

namespace Microsoft.EntityFrameworkCore.Metadata.Internal
namespace Microsoft.EntityFrameworkCore.Metadata
{
/// <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.
/// Extension methods for <see cref="IColumn" />.
/// </summary>
public static class ColumnExtensions
{
/// <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.
/// <para>
/// Creates a human-readable representation of the given metadata.
/// </para>
/// <para>
/// Warning: Do not rely on the format of the returned string.
/// It is designed for debugging only and may change arbitrarily between releases.
/// </para>
/// </summary>
/// <param name="column"> The metadata item. </param>
/// <param name="options"> Options for generating the string. </param>
/// <param name="indent"> The number of indent spaces to use before each new line. </param>
/// <returns> A human-readable representation. </returns>
public static string ToDebugString(
[NotNull] this IColumn column,
MetadataDebugStringOptions options,
[NotNull] string indent = "")
int indent = 0)
{
var builder = new StringBuilder();
var indentString = new string(' ', indent);

builder.Append(indent);
builder.Append(indentString);

var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
if (singleLine)
Expand All @@ -54,7 +59,7 @@ public static string ToDebugString(
if (!singleLine &&
(options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
{
builder.Append(column.AnnotationsToDebugString(indent + " "));
builder.Append(column.AnnotationsToDebugString(indent + 2));
}

return builder.ToString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,35 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;

namespace Microsoft.EntityFrameworkCore.Metadata.Internal
namespace Microsoft.EntityFrameworkCore.Metadata
{
/// <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.
/// Extension methods for <see cref="IColumnMapping" />.
/// </summary>
public static class ColumnMappingExtensions
{
/// <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.
/// <para>
/// Creates a human-readable representation of the given metadata.
/// </para>
/// <para>
/// Warning: Do not rely on the format of the returned string.
/// It is designed for debugging only and may change arbitrarily between releases.
/// </para>
/// </summary>
/// <param name="columnMapping"> The metadata item. </param>
/// <param name="options"> Options for generating the string. </param>
/// <param name="indent"> The number of indent spaces to use before each new line. </param>
/// <returns> A human-readable representation. </returns>
public static string ToDebugString(
[NotNull] this IColumnMapping columnMapping,
MetadataDebugStringOptions options,
[NotNull] string indent = "")
int indent = 0)
{
var builder = new StringBuilder();
var indentString = new string(' ', indent);

builder.Append(indent);
builder.Append(indentString);

var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
if (singleLine)
Expand All @@ -50,7 +55,7 @@ public static string ToDebugString(
if (!singleLine &&
(options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
{
builder.Append(columnMapping.AnnotationsToDebugString(indent + " "));
builder.Append(columnMapping.AnnotationsToDebugString(indent + 2));
}

return builder.ToString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,44 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;

namespace Microsoft.EntityFrameworkCore.Metadata.Internal
namespace Microsoft.EntityFrameworkCore.Metadata
{
/// <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.
/// Extension methods for <see cref="IRelationalModel" />.
/// </summary>
public static class DatabaseModelExtensions
{
/// <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.
/// <para>
/// Creates a human-readable representation of the given metadata.
/// </para>
/// <para>
/// Warning: Do not rely on the format of the returned string.
/// It is designed for debugging only and may change arbitrarily between releases.
/// </para>
/// </summary>
/// <param name="model"> The metadata item. </param>
/// <param name="options"> Options for generating the string. </param>
/// <param name="indent"> The number of indent spaces to use before each new line. </param>
/// <returns> A human-readable representation. </returns>
public static string ToDebugString(
[NotNull] this IRelationalModel model,
MetadataDebugStringOptions options,
[NotNull] string indent = "")
int indent = 0)
{
var builder = new StringBuilder();
var indentString = new string(' ', indent);

builder.Append(indent).Append("DatabaseModel: ");
builder.Append(indentString).Append("DatabaseModel: ");

foreach (var table in model.Tables)
{
builder.AppendLine().Append(table.ToDebugString(options, indent + " "));
builder.AppendLine().Append(table.ToDebugString(options, indent + 2));
}

foreach (var view in model.Views)
{
builder.AppendLine().Append(view.ToDebugString(options, indent + " "));
builder.AppendLine().Append(view.ToDebugString(options, indent + 2));
}

if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,36 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;

namespace Microsoft.EntityFrameworkCore.Metadata.Internal
namespace Microsoft.EntityFrameworkCore.Metadata
{
/// <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.
/// Extension methods for <see cref="IDbFunction" />.
/// </summary>
public static class DbFunctionExtensions
{
/// <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.
/// <para>
/// Creates a human-readable representation of the given metadata.
/// </para>
/// <para>
/// Warning: Do not rely on the format of the returned string.
/// It is designed for debugging only and may change arbitrarily between releases.
/// </para>
/// </summary>
/// <param name="function"> The metadata item. </param>
/// <param name="options"> Options for generating the string. </param>
/// <param name="indent"> The number of indent spaces to use before each new line. </param>
/// <returns> A human-readable representation. </returns>
public static string ToDebugString(
[NotNull] this IDbFunction function,
MetadataDebugStringOptions options,
[NotNull] string indent = "")
int indent = 0)
{
var builder = new StringBuilder();
var indentString = new string(' ', indent);

builder
.Append(indent)
.Append(indentString)
.Append("DbFunction: ");

builder.Append(function.ReturnType.ShortDisplayName())
Expand All @@ -50,16 +55,16 @@ public static string ToDebugString(
var parameters = function.Parameters.ToList();
if (parameters.Count != 0)
{
builder.AppendLine().Append(indent).Append(" Parameters: ");
builder.AppendLine().Append(indentString).Append(" Parameters: ");
foreach (var parameter in parameters)
{
builder.AppendLine().Append(parameter.ToDebugString(options, indent + " "));
builder.AppendLine().Append(parameter.ToDebugString(options, indent + 4));
}
}

if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
{
builder.Append(function.AnnotationsToDebugString(indent: indent + " "));
builder.Append(function.AnnotationsToDebugString(indent: indent + 2));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,36 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;

namespace Microsoft.EntityFrameworkCore.Metadata.Internal
namespace Microsoft.EntityFrameworkCore.Metadata
{
/// <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.
/// Extension methods for <see cref="IDbFunctionParameter" />.
/// </summary>
public static class DbFunctionParameterExtensions
{
/// <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.
/// <para>
/// Creates a human-readable representation of the given metadata.
/// </para>
/// <para>
/// Warning: Do not rely on the format of the returned string.
/// It is designed for debugging only and may change arbitrarily between releases.
/// </para>
/// </summary>
/// <param name="parameter"> The metadata item. </param>
/// <param name="options"> Options for generating the string. </param>
/// <param name="indent"> The number of indent spaces to use before each new line. </param>
/// <returns> A human-readable representation. </returns>
public static string ToDebugString(
[NotNull] this IDbFunctionParameter parameter,
MetadataDebugStringOptions options,
[NotNull] string indent = "")
int indent = 0)
{
var builder = new StringBuilder();
var indentString = new string(' ', indent);

builder
.Append(indent)
.Append(indentString)
.Append("DbFunctionParameter: ");

builder.Append(parameter.Name)
Expand All @@ -40,7 +45,7 @@ public static string ToDebugString(
{
if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
{
builder.Append(parameter.AnnotationsToDebugString(indent: indent + " "));
builder.Append(parameter.AnnotationsToDebugString(indent + 2));
}
}

Expand Down
Loading

0 comments on commit bd625fb

Please sign in to comment.