Update Microsoft.AspNet.Diagnostics.Entity to build in this repo
Previous commit copied code verbatim from EF repo This commit updates it to build in this repo
This commit is contained in:
parent
fad5ba4323
commit
ef544d9baa
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.22228.0
|
||||
VisualStudioVersion = 14.0.22228.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{509A6F36-AD80-4A18-B5B1-717D38DFF29D}"
|
||||
EndProject
|
||||
|
|
@ -28,6 +28,12 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Diagnostic
|
|||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ErrorHandlerSample", "samples\ErrorHandlerSample\ErrorHandlerSample.kproj", "{427CDB36-78B0-4583-9EBC-7F283DE60355}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Diagnostics.Entity", "src\Microsoft.AspNet.Diagnostics.Entity\Microsoft.AspNet.Diagnostics.Entity.kproj", "{4F5A6A72-FFE4-49C4-B4C6-58132CFCB9FE}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Diagnostics.Entity.Tests", "test\Microsoft.AspNet.Diagnostics.Entity.Tests\Microsoft.AspNet.Diagnostics.Entity.Tests.kproj", "{5486117B-A742-49E0-94FC-12B76F061803}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Diagnostics.Entity.FunctionalTests", "test\Microsoft.AspNet.Diagnostics.Entity.FunctionalTests\Microsoft.AspNet.Diagnostics.Entity.FunctionalTests.kproj", "{2F9B479D-8247-4210-804B-78E6DD5C3E98}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -108,6 +114,42 @@ Global
|
|||
{427CDB36-78B0-4583-9EBC-7F283DE60355}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{427CDB36-78B0-4583-9EBC-7F283DE60355}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{427CDB36-78B0-4583-9EBC-7F283DE60355}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{4F5A6A72-FFE4-49C4-B4C6-58132CFCB9FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4F5A6A72-FFE4-49C4-B4C6-58132CFCB9FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4F5A6A72-FFE4-49C4-B4C6-58132CFCB9FE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{4F5A6A72-FFE4-49C4-B4C6-58132CFCB9FE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{4F5A6A72-FFE4-49C4-B4C6-58132CFCB9FE}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{4F5A6A72-FFE4-49C4-B4C6-58132CFCB9FE}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{4F5A6A72-FFE4-49C4-B4C6-58132CFCB9FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4F5A6A72-FFE4-49C4-B4C6-58132CFCB9FE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4F5A6A72-FFE4-49C4-B4C6-58132CFCB9FE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{4F5A6A72-FFE4-49C4-B4C6-58132CFCB9FE}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{4F5A6A72-FFE4-49C4-B4C6-58132CFCB9FE}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{4F5A6A72-FFE4-49C4-B4C6-58132CFCB9FE}.Release|x86.Build.0 = Release|Any CPU
|
||||
{5486117B-A742-49E0-94FC-12B76F061803}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5486117B-A742-49E0-94FC-12B76F061803}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5486117B-A742-49E0-94FC-12B76F061803}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{5486117B-A742-49E0-94FC-12B76F061803}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{5486117B-A742-49E0-94FC-12B76F061803}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{5486117B-A742-49E0-94FC-12B76F061803}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{5486117B-A742-49E0-94FC-12B76F061803}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5486117B-A742-49E0-94FC-12B76F061803}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5486117B-A742-49E0-94FC-12B76F061803}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{5486117B-A742-49E0-94FC-12B76F061803}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{5486117B-A742-49E0-94FC-12B76F061803}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{5486117B-A742-49E0-94FC-12B76F061803}.Release|x86.Build.0 = Release|Any CPU
|
||||
{2F9B479D-8247-4210-804B-78E6DD5C3E98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2F9B479D-8247-4210-804B-78E6DD5C3E98}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2F9B479D-8247-4210-804B-78E6DD5C3E98}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{2F9B479D-8247-4210-804B-78E6DD5C3E98}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{2F9B479D-8247-4210-804B-78E6DD5C3E98}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{2F9B479D-8247-4210-804B-78E6DD5C3E98}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{2F9B479D-8247-4210-804B-78E6DD5C3E98}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2F9B479D-8247-4210-804B-78E6DD5C3E98}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2F9B479D-8247-4210-804B-78E6DD5C3E98}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{2F9B479D-8247-4210-804B-78E6DD5C3E98}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{2F9B479D-8247-4210-804B-78E6DD5C3E98}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{2F9B479D-8247-4210-804B-78E6DD5C3E98}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -120,5 +162,8 @@ Global
|
|||
{CD62A191-39F5-4C86-BC1D-7731085120F5} = {ACAA0157-A8C4-4152-93DE-90CCDF304087}
|
||||
{994351B4-7B2A-4139-8B72-72C5BB5CC618} = {2AF90579-B118-4583-AE88-672EFACB5BC4}
|
||||
{427CDB36-78B0-4583-9EBC-7F283DE60355} = {ACAA0157-A8C4-4152-93DE-90CCDF304087}
|
||||
{4F5A6A72-FFE4-49C4-B4C6-58132CFCB9FE} = {509A6F36-AD80-4A18-B5B1-717D38DFF29D}
|
||||
{5486117B-A742-49E0-94FC-12B76F061803} = {2AF90579-B118-4583-AE88-672EFACB5BC4}
|
||||
{2F9B479D-8247-4210-804B-78E6DD5C3E98} = {2AF90579-B118-4583-AE88-672EFACB5BC4}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
|||
|
|
@ -0,0 +1,107 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace JetBrains.Annotations
|
||||
{
|
||||
[AttributeUsage(
|
||||
AttributeTargets.Method | AttributeTargets.Parameter |
|
||||
AttributeTargets.Property | AttributeTargets.Delegate |
|
||||
AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
internal sealed class NotNullAttribute : Attribute
|
||||
{
|
||||
}
|
||||
|
||||
[AttributeUsage(
|
||||
AttributeTargets.Method | AttributeTargets.Parameter |
|
||||
AttributeTargets.Property | AttributeTargets.Delegate |
|
||||
AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
internal sealed class CanBeNullAttribute : Attribute
|
||||
{
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
|
||||
internal sealed class InvokerParameterNameAttribute : Attribute
|
||||
{
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
|
||||
internal sealed class NoEnumerationAttribute : Attribute
|
||||
{
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
|
||||
internal sealed class ContractAnnotationAttribute : Attribute
|
||||
{
|
||||
public string Contract { get; private set; }
|
||||
|
||||
public bool ForceFullStates { get; private set; }
|
||||
|
||||
public ContractAnnotationAttribute([NotNull] string contract)
|
||||
: this(contract, false)
|
||||
{
|
||||
}
|
||||
|
||||
public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates)
|
||||
{
|
||||
Contract = contract;
|
||||
ForceFullStates = forceFullStates;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
|
||||
internal sealed class UsedImplicitlyAttribute : Attribute
|
||||
{
|
||||
public UsedImplicitlyAttribute()
|
||||
: this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default)
|
||||
{
|
||||
}
|
||||
|
||||
public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags)
|
||||
: this(useKindFlags, ImplicitUseTargetFlags.Default)
|
||||
{
|
||||
}
|
||||
|
||||
public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags)
|
||||
: this(ImplicitUseKindFlags.Default, targetFlags)
|
||||
{
|
||||
}
|
||||
|
||||
public UsedImplicitlyAttribute(
|
||||
ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
|
||||
{
|
||||
UseKindFlags = useKindFlags;
|
||||
TargetFlags = targetFlags;
|
||||
}
|
||||
|
||||
public ImplicitUseKindFlags UseKindFlags { get; private set; }
|
||||
public ImplicitUseTargetFlags TargetFlags { get; private set; }
|
||||
}
|
||||
|
||||
[Flags]
|
||||
internal enum ImplicitUseKindFlags
|
||||
{
|
||||
Default = Access | Assign | InstantiatedWithFixedConstructorSignature,
|
||||
Access = 1,
|
||||
Assign = 2,
|
||||
InstantiatedWithFixedConstructorSignature = 4,
|
||||
InstantiatedNoFixedConstructorSignature = 8,
|
||||
}
|
||||
|
||||
[Flags]
|
||||
internal enum ImplicitUseTargetFlags
|
||||
{
|
||||
Default = Itself,
|
||||
Itself = 1,
|
||||
Members = 2,
|
||||
WithMembers = Itself | Members
|
||||
}
|
||||
}
|
||||
|
||||
namespace Microsoft.Data.Entity.Relational.Utilities
|
||||
{
|
||||
internal sealed class ValidatedNotNullAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
var dbContext = (DbContext)context.RequestServices.GetService(dbContextType);
|
||||
if (dbContext == null)
|
||||
{
|
||||
_logger.WriteError(Strings.DatabaseErrorPageMiddleware_ContextNotRegistered(dbContextType.FullName));
|
||||
_logger.WriteError(Strings.FormatDatabaseErrorPageMiddleware_ContextNotRegistered(dbContextType.FullName));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
|
||||
if (context.Request.Path.Equals(_options.Path))
|
||||
{
|
||||
_logger.WriteVerbose(Strings.MigrationsEndPointMiddleware_RequestPathMatched(context.Request.Path));
|
||||
_logger.WriteVerbose(Strings.FormatMigrationsEndPointMiddleware_RequestPathMatched(context.Request.Path));
|
||||
|
||||
using (RequestServicesContainer.EnsureRequestServices(context, _serviceProvider))
|
||||
{
|
||||
|
|
@ -51,7 +51,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
{
|
||||
try
|
||||
{
|
||||
_logger.WriteVerbose(Strings.MigrationsEndPointMiddleware_ApplyingMigrations(db.GetType().FullName));
|
||||
_logger.WriteVerbose(Strings.FormatMigrationsEndPointMiddleware_ApplyingMigrations(db.GetType().FullName));
|
||||
|
||||
db.Database.AsMigrationsEnabled().ApplyMigrations();
|
||||
|
||||
|
|
@ -59,11 +59,11 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
context.Response.Headers.Add("Pragma", new[] { "no-cache" });
|
||||
context.Response.Headers.Add("Cache-Control", new[] { "no-cache" });
|
||||
|
||||
_logger.WriteVerbose(Strings.MigrationsEndPointMiddleware_Applied(db.GetType().FullName));
|
||||
_logger.WriteVerbose(Strings.FormatMigrationsEndPointMiddleware_Applied(db.GetType().FullName));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var message = Strings.MigrationsEndPointMiddleware_Exception(db.GetType().FullName);
|
||||
var message = Strings.FormatMigrationsEndPointMiddleware_Exception(db.GetType().FullName);
|
||||
_logger.WriteError(message);
|
||||
throw new InvalidOperationException(message, ex);
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
var contextType = Type.GetType(contextTypeName);
|
||||
if (contextType == null)
|
||||
{
|
||||
var message = Strings.MigrationsEndPointMiddleware_InvalidContextType(contextTypeName);
|
||||
var message = Strings.FormatMigrationsEndPointMiddleware_InvalidContextType(contextTypeName);
|
||||
logger.WriteError(message);
|
||||
await WriteErrorToResponse(context.Response, message).WithCurrentCulture();
|
||||
return null;
|
||||
|
|
@ -99,7 +99,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
var db = (DbContext)context.RequestServices.GetService(contextType);
|
||||
if (db == null)
|
||||
{
|
||||
var message = Strings.MigrationsEndPointMiddleware_ContextNotRegistered(contextType.FullName);
|
||||
var message = Strings.FormatMigrationsEndPointMiddleware_ContextNotRegistered(contextType.FullName);
|
||||
logger.WriteError(message);
|
||||
await WriteErrorToResponse(context.Response, message).WithCurrentCulture();
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
// <auto-generated />
|
||||
namespace Microsoft.AspNet.Diagnostics.Entity
|
||||
{
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
public static class Strings
|
||||
internal static class Strings
|
||||
{
|
||||
private static readonly ResourceManager _resourceManager
|
||||
= new ResourceManager("Microsoft.AspNet.Diagnostics.Entity.Strings", typeof(Strings).GetTypeInfo().Assembly);
|
||||
|
|
@ -15,7 +13,15 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
/// <summary>
|
||||
/// The string argument '{argumentName}' cannot be empty.
|
||||
/// </summary>
|
||||
public static string ArgumentIsEmpty([CanBeNull] object argumentName)
|
||||
internal static string ArgumentIsEmpty
|
||||
{
|
||||
get { return GetString("ArgumentIsEmpty"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The string argument '{argumentName}' cannot be empty.
|
||||
/// </summary>
|
||||
internal static string FormatArgumentIsEmpty(object argumentName)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("ArgumentIsEmpty", "argumentName"), argumentName);
|
||||
}
|
||||
|
|
@ -23,7 +29,15 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
/// <summary>
|
||||
/// The collection argument '{argumentName}' must contain at least one element.
|
||||
/// </summary>
|
||||
public static string CollectionArgumentIsEmpty([CanBeNull] object argumentName)
|
||||
internal static string CollectionArgumentIsEmpty
|
||||
{
|
||||
get { return GetString("CollectionArgumentIsEmpty"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The collection argument '{argumentName}' must contain at least one element.
|
||||
/// </summary>
|
||||
internal static string FormatCollectionArgumentIsEmpty(object argumentName)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("CollectionArgumentIsEmpty", "argumentName"), argumentName);
|
||||
}
|
||||
|
|
@ -31,7 +45,15 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
/// <summary>
|
||||
/// The context type '{0}' was not found in services. This usually means the context was not registered in services during startup. You probably want to call AddScoped<{0}>() inside the UseServices(...) call in your application startup code. Skipping display of the database error page.
|
||||
/// </summary>
|
||||
public static string DatabaseErrorPageMiddleware_ContextNotRegistered([CanBeNull] object p0)
|
||||
internal static string DatabaseErrorPageMiddleware_ContextNotRegistered
|
||||
{
|
||||
get { return GetString("DatabaseErrorPageMiddleware_ContextNotRegistered"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The context type '{0}' was not found in services. This usually means the context was not registered in services during startup. You probably want to call AddScoped<{0}>() inside the UseServices(...) call in your application startup code. Skipping display of the database error page.
|
||||
/// </summary>
|
||||
internal static string FormatDatabaseErrorPageMiddleware_ContextNotRegistered(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("DatabaseErrorPageMiddleware_ContextNotRegistered"), p0);
|
||||
}
|
||||
|
|
@ -39,79 +61,159 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
/// <summary>
|
||||
/// An exception occurred while calculating the database error page content. Skipping display of the database error page.
|
||||
/// </summary>
|
||||
public static string DatabaseErrorPageMiddleware_Exception
|
||||
internal static string DatabaseErrorPageMiddleware_Exception
|
||||
{
|
||||
get { return GetString("DatabaseErrorPageMiddleware_Exception"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An exception occurred while calculating the database error page content. Skipping display of the database error page.
|
||||
/// </summary>
|
||||
internal static string FormatDatabaseErrorPageMiddleware_Exception()
|
||||
{
|
||||
return GetString("DatabaseErrorPageMiddleware_Exception");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// > k ef migration add [migration name]
|
||||
/// </summary>
|
||||
public static string DatabaseErrorPage_AddMigrationCommand
|
||||
internal static string DatabaseErrorPage_AddMigrationCommand
|
||||
{
|
||||
get { return GetString("DatabaseErrorPage_AddMigrationCommand"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// > k ef migration add [migration name]
|
||||
/// </summary>
|
||||
internal static string FormatDatabaseErrorPage_AddMigrationCommand()
|
||||
{
|
||||
return GetString("DatabaseErrorPage_AddMigrationCommand");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Apply Migrations
|
||||
/// </summary>
|
||||
public static string DatabaseErrorPage_ApplyMigrationsButton
|
||||
internal static string DatabaseErrorPage_ApplyMigrationsButton
|
||||
{
|
||||
get { return GetString("DatabaseErrorPage_ApplyMigrationsButton"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Apply Migrations
|
||||
/// </summary>
|
||||
internal static string FormatDatabaseErrorPage_ApplyMigrationsButton()
|
||||
{
|
||||
return GetString("DatabaseErrorPage_ApplyMigrationsButton");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Migrations Applied
|
||||
/// </summary>
|
||||
public static string DatabaseErrorPage_ApplyMigrationsButtonDone
|
||||
internal static string DatabaseErrorPage_ApplyMigrationsButtonDone
|
||||
{
|
||||
get { return GetString("DatabaseErrorPage_ApplyMigrationsButtonDone"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Migrations Applied
|
||||
/// </summary>
|
||||
internal static string FormatDatabaseErrorPage_ApplyMigrationsButtonDone()
|
||||
{
|
||||
return GetString("DatabaseErrorPage_ApplyMigrationsButtonDone");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applying Migrations...
|
||||
/// </summary>
|
||||
public static string DatabaseErrorPage_ApplyMigrationsButtonRunning
|
||||
internal static string DatabaseErrorPage_ApplyMigrationsButtonRunning
|
||||
{
|
||||
get { return GetString("DatabaseErrorPage_ApplyMigrationsButtonRunning"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applying Migrations...
|
||||
/// </summary>
|
||||
internal static string FormatDatabaseErrorPage_ApplyMigrationsButtonRunning()
|
||||
{
|
||||
return GetString("DatabaseErrorPage_ApplyMigrationsButtonRunning");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An error occurred applying migrations, try applying them from the command line
|
||||
/// </summary>
|
||||
public static string DatabaseErrorPage_ApplyMigrationsFailed
|
||||
internal static string DatabaseErrorPage_ApplyMigrationsFailed
|
||||
{
|
||||
get { return GetString("DatabaseErrorPage_ApplyMigrationsFailed"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An error occurred applying migrations, try applying them from the command line
|
||||
/// </summary>
|
||||
internal static string FormatDatabaseErrorPage_ApplyMigrationsFailed()
|
||||
{
|
||||
return GetString("DatabaseErrorPage_ApplyMigrationsFailed");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// You can also apply migrations from the command line:
|
||||
/// </summary>
|
||||
public static string DatabaseErrorPage_HowToApplyFromCmd
|
||||
internal static string DatabaseErrorPage_HowToApplyFromCmd
|
||||
{
|
||||
get { return GetString("DatabaseErrorPage_HowToApplyFromCmd"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// You can also apply migrations from the command line:
|
||||
/// </summary>
|
||||
internal static string FormatDatabaseErrorPage_HowToApplyFromCmd()
|
||||
{
|
||||
return GetString("DatabaseErrorPage_HowToApplyFromCmd");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Try refreshing the page
|
||||
/// </summary>
|
||||
public static string DatabaseErrorPage_MigrationsAppliedRefresh
|
||||
internal static string DatabaseErrorPage_MigrationsAppliedRefresh
|
||||
{
|
||||
get { return GetString("DatabaseErrorPage_MigrationsAppliedRefresh"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Try refreshing the page
|
||||
/// </summary>
|
||||
internal static string FormatDatabaseErrorPage_MigrationsAppliedRefresh()
|
||||
{
|
||||
return GetString("DatabaseErrorPage_MigrationsAppliedRefresh");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// From the command line, scaffold a new migration and apply it to the database:
|
||||
/// </summary>
|
||||
public static string DatabaseErrorPage_NoDbOrMigrationsInfo
|
||||
internal static string DatabaseErrorPage_NoDbOrMigrationsInfo
|
||||
{
|
||||
get { return GetString("DatabaseErrorPage_NoDbOrMigrationsInfo"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// From the command line, scaffold a new migration and apply it to the database:
|
||||
/// </summary>
|
||||
internal static string FormatDatabaseErrorPage_NoDbOrMigrationsInfo()
|
||||
{
|
||||
return GetString("DatabaseErrorPage_NoDbOrMigrationsInfo");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use migrations to create the database for {0}
|
||||
/// </summary>
|
||||
public static string DatabaseErrorPage_NoDbOrMigrationsTitle([CanBeNull] object p0)
|
||||
internal static string DatabaseErrorPage_NoDbOrMigrationsTitle
|
||||
{
|
||||
get { return GetString("DatabaseErrorPage_NoDbOrMigrationsTitle"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use migrations to create the database for {0}
|
||||
/// </summary>
|
||||
internal static string FormatDatabaseErrorPage_NoDbOrMigrationsTitle(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("DatabaseErrorPage_NoDbOrMigrationsTitle"), p0);
|
||||
}
|
||||
|
|
@ -119,15 +221,31 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
/// <summary>
|
||||
/// Scaffold a new migration for these changes and apply them to the database from the command line:
|
||||
/// </summary>
|
||||
public static string DatabaseErrorPage_PendingChangesInfo
|
||||
internal static string DatabaseErrorPage_PendingChangesInfo
|
||||
{
|
||||
get { return GetString("DatabaseErrorPage_PendingChangesInfo"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scaffold a new migration for these changes and apply them to the database from the command line:
|
||||
/// </summary>
|
||||
internal static string FormatDatabaseErrorPage_PendingChangesInfo()
|
||||
{
|
||||
return GetString("DatabaseErrorPage_PendingChangesInfo");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// There are pending model changes for {0}
|
||||
/// </summary>
|
||||
public static string DatabaseErrorPage_PendingChangesTitle([CanBeNull] object p0)
|
||||
internal static string DatabaseErrorPage_PendingChangesTitle
|
||||
{
|
||||
get { return GetString("DatabaseErrorPage_PendingChangesTitle"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// There are pending model changes for {0}
|
||||
/// </summary>
|
||||
internal static string FormatDatabaseErrorPage_PendingChangesTitle(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("DatabaseErrorPage_PendingChangesTitle"), p0);
|
||||
}
|
||||
|
|
@ -135,7 +253,15 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
/// <summary>
|
||||
/// There are migrations for {0} that have not been applied to the database
|
||||
/// </summary>
|
||||
public static string DatabaseErrorPage_PendingMigrationsInfo([CanBeNull] object p0)
|
||||
internal static string DatabaseErrorPage_PendingMigrationsInfo
|
||||
{
|
||||
get { return GetString("DatabaseErrorPage_PendingMigrationsInfo"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// There are migrations for {0} that have not been applied to the database
|
||||
/// </summary>
|
||||
internal static string FormatDatabaseErrorPage_PendingMigrationsInfo(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("DatabaseErrorPage_PendingMigrationsInfo"), p0);
|
||||
}
|
||||
|
|
@ -143,7 +269,15 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
/// <summary>
|
||||
/// Applying existing migrations for {0} may resolve this issue
|
||||
/// </summary>
|
||||
public static string DatabaseErrorPage_PendingMigrationsTitle([CanBeNull] object p0)
|
||||
internal static string DatabaseErrorPage_PendingMigrationsTitle
|
||||
{
|
||||
get { return GetString("DatabaseErrorPage_PendingMigrationsTitle"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applying existing migrations for {0} may resolve this issue
|
||||
/// </summary>
|
||||
internal static string FormatDatabaseErrorPage_PendingMigrationsTitle(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("DatabaseErrorPage_PendingMigrationsTitle"), p0);
|
||||
}
|
||||
|
|
@ -151,15 +285,31 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
/// <summary>
|
||||
/// > k ef migration apply
|
||||
/// </summary>
|
||||
public static string DatabaseErrorPage_ApplyMigrationsCommand
|
||||
internal static string DatabaseErrorPage_ApplyMigrationsCommand
|
||||
{
|
||||
get { return GetString("DatabaseErrorPage_ApplyMigrationsCommand"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// > k ef migration apply
|
||||
/// </summary>
|
||||
internal static string FormatDatabaseErrorPage_ApplyMigrationsCommand()
|
||||
{
|
||||
return GetString("DatabaseErrorPage_ApplyMigrationsCommand");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The value provided for argument '{argumentName}' must be a valid value of enum type '{enumType}'.
|
||||
/// </summary>
|
||||
public static string InvalidEnumValue([CanBeNull] object argumentName, [CanBeNull] object enumType)
|
||||
internal static string InvalidEnumValue
|
||||
{
|
||||
get { return GetString("InvalidEnumValue"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The value provided for argument '{argumentName}' must be a valid value of enum type '{enumType}'.
|
||||
/// </summary>
|
||||
internal static string FormatInvalidEnumValue(object argumentName, object enumType)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("InvalidEnumValue", "argumentName", "enumType"), argumentName, enumType);
|
||||
}
|
||||
|
|
@ -167,7 +317,15 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
/// <summary>
|
||||
/// Migrations successfully applied for context '{0}'.
|
||||
/// </summary>
|
||||
public static string MigrationsEndPointMiddleware_Applied([CanBeNull] object p0)
|
||||
internal static string MigrationsEndPointMiddleware_Applied
|
||||
{
|
||||
get { return GetString("MigrationsEndPointMiddleware_Applied"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Migrations successfully applied for context '{0}'.
|
||||
/// </summary>
|
||||
internal static string FormatMigrationsEndPointMiddleware_Applied(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("MigrationsEndPointMiddleware_Applied"), p0);
|
||||
}
|
||||
|
|
@ -175,7 +333,15 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
/// <summary>
|
||||
/// Request is valid, applying migrations for context '{0}'.
|
||||
/// </summary>
|
||||
public static string MigrationsEndPointMiddleware_ApplyingMigrations([CanBeNull] object p0)
|
||||
internal static string MigrationsEndPointMiddleware_ApplyingMigrations
|
||||
{
|
||||
get { return GetString("MigrationsEndPointMiddleware_ApplyingMigrations"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request is valid, applying migrations for context '{0}'.
|
||||
/// </summary>
|
||||
internal static string FormatMigrationsEndPointMiddleware_ApplyingMigrations(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("MigrationsEndPointMiddleware_ApplyingMigrations"), p0);
|
||||
}
|
||||
|
|
@ -183,7 +349,15 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
/// <summary>
|
||||
/// The context type '{0}' was not found in services. This usually means the context was not registered in services during startup. You probably want to call AddScoped<{0}>() inside the UseServices(...) call in your application startup code.
|
||||
/// </summary>
|
||||
public static string MigrationsEndPointMiddleware_ContextNotRegistered([CanBeNull] object p0)
|
||||
internal static string MigrationsEndPointMiddleware_ContextNotRegistered
|
||||
{
|
||||
get { return GetString("MigrationsEndPointMiddleware_ContextNotRegistered"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The context type '{0}' was not found in services. This usually means the context was not registered in services during startup. You probably want to call AddScoped<{0}>() inside the UseServices(...) call in your application startup code.
|
||||
/// </summary>
|
||||
internal static string FormatMigrationsEndPointMiddleware_ContextNotRegistered(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("MigrationsEndPointMiddleware_ContextNotRegistered"), p0);
|
||||
}
|
||||
|
|
@ -191,7 +365,15 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
/// <summary>
|
||||
/// An error occurred while applying the migrations for '{0}'. See InnerException for details.
|
||||
/// </summary>
|
||||
public static string MigrationsEndPointMiddleware_Exception([CanBeNull] object p0)
|
||||
internal static string MigrationsEndPointMiddleware_Exception
|
||||
{
|
||||
get { return GetString("MigrationsEndPointMiddleware_Exception"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An error occurred while applying the migrations for '{0}'. See InnerException for details.
|
||||
/// </summary>
|
||||
internal static string FormatMigrationsEndPointMiddleware_Exception(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("MigrationsEndPointMiddleware_Exception"), p0);
|
||||
}
|
||||
|
|
@ -199,7 +381,15 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
/// <summary>
|
||||
/// The context type '{0}' could not be loaded. Ensure this is the correct type name for the context you are trying to apply migrations for.
|
||||
/// </summary>
|
||||
public static string MigrationsEndPointMiddleware_InvalidContextType([CanBeNull] object p0)
|
||||
internal static string MigrationsEndPointMiddleware_InvalidContextType
|
||||
{
|
||||
get { return GetString("MigrationsEndPointMiddleware_InvalidContextType"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The context type '{0}' could not be loaded. Ensure this is the correct type name for the context you are trying to apply migrations for.
|
||||
/// </summary>
|
||||
internal static string FormatMigrationsEndPointMiddleware_InvalidContextType(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("MigrationsEndPointMiddleware_InvalidContextType"), p0);
|
||||
}
|
||||
|
|
@ -207,15 +397,31 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
/// <summary>
|
||||
/// No context type was specified. Ensure the form data from the request includes a contextTypeName value, specifying the context to apply migrations for.
|
||||
/// </summary>
|
||||
public static string MigrationsEndPointMiddleware_NoContextType
|
||||
internal static string MigrationsEndPointMiddleware_NoContextType
|
||||
{
|
||||
get { return GetString("MigrationsEndPointMiddleware_NoContextType"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// No context type was specified. Ensure the form data from the request includes a contextTypeName value, specifying the context to apply migrations for.
|
||||
/// </summary>
|
||||
internal static string FormatMigrationsEndPointMiddleware_NoContextType()
|
||||
{
|
||||
return GetString("MigrationsEndPointMiddleware_NoContextType");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request path matched the path configured for this migrations endpoint ({0}). Attempting to process the migrations request.
|
||||
/// </summary>
|
||||
public static string MigrationsEndPointMiddleware_RequestPathMatched([CanBeNull] object p0)
|
||||
internal static string MigrationsEndPointMiddleware_RequestPathMatched
|
||||
{
|
||||
get { return GetString("MigrationsEndPointMiddleware_RequestPathMatched"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request path matched the path configured for this migrations endpoint ({0}). Attempting to process the migrations request.
|
||||
/// </summary>
|
||||
internal static string FormatMigrationsEndPointMiddleware_RequestPathMatched(object p0)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("MigrationsEndPointMiddleware_RequestPathMatched"), p0);
|
||||
}
|
||||
|
|
@ -223,24 +429,40 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
/// <summary>
|
||||
/// A database operation failed while processing the request.
|
||||
/// </summary>
|
||||
public static string DatabaseErrorPage_Title
|
||||
internal static string DatabaseErrorPage_Title
|
||||
{
|
||||
get { return GetString("DatabaseErrorPage_Title"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A database operation failed while processing the request.
|
||||
/// </summary>
|
||||
internal static string FormatDatabaseErrorPage_Title()
|
||||
{
|
||||
return GetString("DatabaseErrorPage_Title");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To use migrations from a command prompt you will need to <a href='http://go.microsoft.com/fwlink/?LinkId=518242'>install K Version Manager (KVM)</a>. Once installed, you can run migration commands from a standard command prompt in the project directory.
|
||||
/// </summary>
|
||||
public static string DatabaseErrorPage_EnableMigrationsCommandsInfo
|
||||
internal static string DatabaseErrorPage_EnableMigrationsCommandsInfo
|
||||
{
|
||||
get { return GetString("DatabaseErrorPage_EnableMigrationsCommandsInfo"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To use migrations from a command prompt you will need to <a href='http://go.microsoft.com/fwlink/?LinkId=518242'>install K Version Manager (KVM)</a>. Once installed, you can run migration commands from a standard command prompt in the project directory.
|
||||
/// </summary>
|
||||
internal static string FormatDatabaseErrorPage_EnableMigrationsCommandsInfo()
|
||||
{
|
||||
return GetString("DatabaseErrorPage_EnableMigrationsCommandsInfo");
|
||||
}
|
||||
|
||||
private static string GetString(string name, params string[] formatterNames)
|
||||
{
|
||||
var value = _resourceManager.GetString(name);
|
||||
|
||||
Debug.Assert(value != null);
|
||||
System.Diagnostics.Debug.Assert(value != null);
|
||||
|
||||
if (formatterNames != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Utilities
|
|||
|
||||
if (value.Count == 0)
|
||||
{
|
||||
throw new ArgumentException(Strings.CollectionArgumentIsEmpty(parameterName));
|
||||
throw new ArgumentException(Strings.FormatCollectionArgumentIsEmpty(parameterName));
|
||||
}
|
||||
|
||||
return value;
|
||||
|
|
@ -48,7 +48,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Utilities
|
|||
|
||||
if (parameterName.Length == 0)
|
||||
{
|
||||
throw new ArgumentException(Strings.ArgumentIsEmpty("parameterName"));
|
||||
throw new ArgumentException(Strings.FormatArgumentIsEmpty("parameterName"));
|
||||
}
|
||||
|
||||
if (ReferenceEquals(value, null))
|
||||
|
|
@ -58,7 +58,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Utilities
|
|||
|
||||
if (value.Length == 0)
|
||||
{
|
||||
throw new ArgumentException(Strings.ArgumentIsEmpty(parameterName));
|
||||
throw new ArgumentException(Strings.FormatArgumentIsEmpty(parameterName));
|
||||
}
|
||||
|
||||
return value;
|
||||
|
|
@ -71,7 +71,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Utilities
|
|||
|
||||
if (!Enum.IsDefined(typeof(T), value))
|
||||
{
|
||||
throw new ArgumentException(Strings.InvalidEnumValue(parameterName, typeof(T)));
|
||||
throw new ArgumentException(Strings.FormatInvalidEnumValue(parameterName, typeof(T)));
|
||||
}
|
||||
|
||||
return value;
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ using Microsoft.AspNet.Diagnostics.Entity.Views
|
|||
|
||||
WriteLiteral(" <h2>");
|
||||
#line 56 "DatabaseErrorPage.cshtml"
|
||||
Write(Strings.DatabaseErrorPage_NoDbOrMigrationsTitle(Model.ContextType.Name));
|
||||
Write(Strings.FormatDatabaseErrorPage_NoDbOrMigrationsTitle(Model.ContextType.Name));
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
|
@ -198,13 +198,13 @@ using Microsoft.AspNet.Diagnostics.Entity.Views
|
|||
|
||||
WriteLiteral(" <div>\r\n <h2>");
|
||||
#line 67 "DatabaseErrorPage.cshtml"
|
||||
Write(Strings.DatabaseErrorPage_PendingMigrationsTitle(Model.ContextType.Name));
|
||||
Write(Strings.FormatDatabaseErrorPage_PendingMigrationsTitle(Model.ContextType.Name));
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</h2>\r\n <p>");
|
||||
#line 68 "DatabaseErrorPage.cshtml"
|
||||
Write(Strings.DatabaseErrorPage_PendingMigrationsInfo(Model.ContextType.Name));
|
||||
Write(Strings.FormatDatabaseErrorPage_PendingMigrationsInfo(Model.ContextType.Name));
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
|
@ -387,7 +387,7 @@ using Microsoft.AspNet.Diagnostics.Entity.Views
|
|||
|
||||
WriteLiteral(" <div>\r\n <h2>");
|
||||
#line 133 "DatabaseErrorPage.cshtml"
|
||||
Write(Strings.DatabaseErrorPage_PendingChangesTitle(Model.ContextType.Name));
|
||||
Write(Strings.FormatDatabaseErrorPage_PendingChangesTitle(Model.ContextType.Name));
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
|
||||
@if (!Model.DatabaseExists && !Model.PendingMigrations.Any())
|
||||
{
|
||||
<h2>@Strings.DatabaseErrorPage_NoDbOrMigrationsTitle(Model.ContextType.Name)</h2>
|
||||
<h2>@Strings.FormatDatabaseErrorPage_NoDbOrMigrationsTitle(Model.ContextType.Name)</h2>
|
||||
<p>@Strings.DatabaseErrorPage_NoDbOrMigrationsInfo</p>
|
||||
<code> @Strings.DatabaseErrorPage_AddMigrationCommand </code>
|
||||
<br />
|
||||
|
|
@ -64,8 +64,8 @@
|
|||
else if (Model.PendingMigrations.Any())
|
||||
{
|
||||
<div>
|
||||
<h2>@Strings.DatabaseErrorPage_PendingMigrationsTitle(Model.ContextType.Name)</h2>
|
||||
<p>@Strings.DatabaseErrorPage_PendingMigrationsInfo(Model.ContextType.Name)</p>
|
||||
<h2>@Strings.FormatDatabaseErrorPage_PendingMigrationsTitle(Model.ContextType.Name)</h2>
|
||||
<p>@Strings.FormatDatabaseErrorPage_PendingMigrationsInfo(Model.ContextType.Name)</p>
|
||||
|
||||
@if (Model.Options.ListMigrations)
|
||||
{
|
||||
|
|
@ -130,7 +130,7 @@
|
|||
else if (Model.PendingModelChanges)
|
||||
{
|
||||
<div>
|
||||
<h2>@Strings.DatabaseErrorPage_PendingChangesTitle(Model.ContextType.Name)</h2>
|
||||
<h2>@Strings.FormatDatabaseErrorPage_PendingChangesTitle(Model.ContextType.Name)</h2>
|
||||
<p>@Strings.DatabaseErrorPage_PendingChangesInfo</p>
|
||||
<code>@Strings.DatabaseErrorPage_AddMigrationCommand</code>
|
||||
<br />
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ using Microsoft.AspNet.Http;
|
|||
using Microsoft.AspNet.TestHost;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Data.Entity.Migrations.Infrastructure;
|
||||
using Microsoft.Data.Entity.SqlServer.FunctionalTests;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.Logging;
|
||||
using Xunit;
|
||||
using Microsoft.AspNet.Diagnostics.Entity.Tests.Helpers;
|
||||
|
||||
namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
||||
{
|
||||
|
|
@ -75,14 +75,14 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
|||
[Fact]
|
||||
public async Task Error_page_displayed_no_migrations()
|
||||
{
|
||||
TestServer server = await SetupTestServer<BloggingContext, NoMigrationsMiddleware>();
|
||||
TestServer server = SetupTestServer<BloggingContext, NoMigrationsMiddleware>();
|
||||
HttpResponseMessage response = await server.CreateClient().GetAsync("http://localhost/");
|
||||
|
||||
Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
Assert.Contains(Strings.DatabaseErrorPage_NoDbOrMigrationsTitle(typeof(BloggingContext).Name), content);
|
||||
Assert.Contains(Strings.DatabaseErrorPage_AddMigrationCommand.Replace(">", ">"), content);
|
||||
Assert.Contains(Strings.DatabaseErrorPage_ApplyMigrationsCommand.Replace(">", ">"), content);
|
||||
Assert.Contains(StringsHelpers.GetResourceString("FormatDatabaseErrorPage_NoDbOrMigrationsTitle", typeof(BloggingContext).Name), content);
|
||||
Assert.Contains(StringsHelpers.GetResourceString("FormatDatabaseErrorPage_AddMigrationCommand").Replace(">", ">"), content);
|
||||
Assert.Contains(StringsHelpers.GetResourceString("FormatDatabaseErrorPage_ApplyMigrationsCommand").Replace(">", ">"), content);
|
||||
}
|
||||
|
||||
class NoMigrationsMiddleware
|
||||
|
|
@ -104,18 +104,18 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
|||
[Fact]
|
||||
public async Task Error_page_displayed_pending_migrations()
|
||||
{
|
||||
TestServer server = await SetupTestServer<BloggingContextWithMigrations, PendingMigrationsMiddleware>();
|
||||
TestServer server = SetupTestServer<BloggingContextWithMigrations, PendingMigrationsMiddleware>();
|
||||
HttpResponseMessage response = await server.CreateClient().GetAsync("http://localhost/");
|
||||
|
||||
Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
|
||||
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
Assert.Contains(Strings.DatabaseErrorPage_PendingMigrationsTitle(typeof(BloggingContextWithMigrations).Name), content);
|
||||
Assert.Contains(Strings.DatabaseErrorPage_ApplyMigrationsCommand.Replace(">", ">"), content);
|
||||
Assert.Contains(StringsHelpers.GetResourceString("FormatDatabaseErrorPage_PendingMigrationsTitle", typeof(BloggingContextWithMigrations).Name), content);
|
||||
Assert.Contains(StringsHelpers.GetResourceString("FormatDatabaseErrorPage_ApplyMigrationsCommand").Replace(">", ">"), content);
|
||||
Assert.Contains("<li>111111111111111_MigrationOne</li>", content);
|
||||
Assert.Contains("<li>222222222222222_MigrationTwo</li>", content);
|
||||
|
||||
Assert.DoesNotContain(Strings.DatabaseErrorPage_AddMigrationCommand.Replace(">", ">"), content);
|
||||
Assert.DoesNotContain(StringsHelpers.GetResourceString("FormatDatabaseErrorPage_AddMigrationCommand").Replace(">", ">"), content);
|
||||
}
|
||||
|
||||
class PendingMigrationsMiddleware
|
||||
|
|
@ -137,15 +137,15 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
|||
[Fact]
|
||||
public async Task Error_page_displayed_pending_model_changes()
|
||||
{
|
||||
TestServer server = await SetupTestServer<BloggingContextWithPendingModelChanges, PendingModelChangesMiddleware>();
|
||||
TestServer server = SetupTestServer<BloggingContextWithPendingModelChanges, PendingModelChangesMiddleware>();
|
||||
HttpResponseMessage response = await server.CreateClient().GetAsync("http://localhost/");
|
||||
|
||||
Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
|
||||
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
Assert.Contains(Strings.DatabaseErrorPage_PendingChangesTitle(typeof(BloggingContextWithPendingModelChanges).Name), content);
|
||||
Assert.Contains(Strings.DatabaseErrorPage_AddMigrationCommand.Replace(">", ">"), content);
|
||||
Assert.Contains(Strings.DatabaseErrorPage_ApplyMigrationsCommand.Replace(">", ">"), content);
|
||||
Assert.Contains(StringsHelpers.GetResourceString("FormatDatabaseErrorPage_PendingChangesTitle", typeof(BloggingContextWithPendingModelChanges).Name), content);
|
||||
Assert.Contains(StringsHelpers.GetResourceString("FormatDatabaseErrorPage_AddMigrationCommand").Replace(">", ">"), content);
|
||||
Assert.Contains(StringsHelpers.GetResourceString("FormatDatabaseErrorPage_ApplyMigrationsCommand").Replace(">", ">"), content);
|
||||
}
|
||||
|
||||
class PendingModelChangesMiddleware
|
||||
|
|
@ -170,7 +170,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
|||
[Fact]
|
||||
public async Task Error_page_then_apply_migrations()
|
||||
{
|
||||
TestServer server = await SetupTestServer<BloggingContextWithMigrations, ApplyMigrationsMiddleware>();
|
||||
TestServer server = SetupTestServer<BloggingContextWithMigrations, ApplyMigrationsMiddleware>();
|
||||
var client = server.CreateClient();
|
||||
|
||||
var expectedMigrationsEndpoint = "/ApplyDatabaseMigrations";
|
||||
|
|
@ -223,7 +223,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
|||
{
|
||||
var migrationsEndpoint = "/MyCustomEndPoints/ApplyMyMigrationsHere";
|
||||
|
||||
using (var database = await SqlServerTestStore.CreateScratchAsync(createDatabase: false))
|
||||
using (var database = SqlServerTestStore.CreateScratch())
|
||||
{
|
||||
var server = TestServer.Create(app =>
|
||||
{
|
||||
|
|
@ -231,7 +231,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
|||
{
|
||||
services.AddEntityFramework().AddSqlServer();
|
||||
services.AddScoped<BloggingContextWithMigrations>();
|
||||
services.AddInstance<DbContextOptions>(new DbContextOptions().UseSqlServer(database.Connection.ConnectionString));
|
||||
services.AddInstance<DbContextOptions>(new DbContextOptions().UseSqlServer(database.ConnectionString));
|
||||
});
|
||||
|
||||
var options = DatabaseErrorPageOptions.ShowAll;
|
||||
|
|
@ -253,7 +253,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
|||
[Fact]
|
||||
public async Task Pass_thru_when_context_not_in_services()
|
||||
{
|
||||
using (var database = await SqlServerTestStore.CreateScratchAsync(createDatabase: false))
|
||||
using (var database = SqlServerTestStore.CreateScratch())
|
||||
{
|
||||
var logProvider = new TestLoggerProvider();
|
||||
|
||||
|
|
@ -266,7 +266,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
|||
|
||||
services.AddInstance<DbContextOptions>(
|
||||
new DbContextOptions()
|
||||
.UseSqlServer(database.Connection.ConnectionString));
|
||||
.UseSqlServer(database.ConnectionString));
|
||||
});
|
||||
|
||||
app.UseDatabaseErrorPage();
|
||||
|
|
@ -280,7 +280,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
|||
await server.CreateClient().GetAsync("http://localhost/"));
|
||||
|
||||
Assert.True(logProvider.Logger.Messages.Any(m =>
|
||||
m.StartsWith(Strings.DatabaseErrorPageMiddleware_ContextNotRegistered(typeof(BloggingContext)))));
|
||||
m.StartsWith(StringsHelpers.GetResourceString("FormatDatabaseErrorPageMiddleware_ContextNotRegistered", typeof(BloggingContext)))));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -304,17 +304,17 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
|||
[Fact]
|
||||
public async Task Pass_thru_when_exception_in_logic()
|
||||
{
|
||||
using (var database = await SqlServerTestStore.CreateScratchAsync(createDatabase: false))
|
||||
using (var database = SqlServerTestStore.CreateScratch())
|
||||
{
|
||||
var logProvider = new TestLoggerProvider();
|
||||
|
||||
var server = await SetupTestServer<BloggingContextWithSnapshotThatThrows, ExceptionInLogicMiddleware>(logProvider);
|
||||
var server = SetupTestServer<BloggingContextWithSnapshotThatThrows, ExceptionInLogicMiddleware>(logProvider);
|
||||
|
||||
var ex = await Assert.ThrowsAsync<SqlException>(async () =>
|
||||
await server.CreateClient().GetAsync("http://localhost/"));
|
||||
|
||||
Assert.True(logProvider.Logger.Messages.Any(m =>
|
||||
m.StartsWith(Strings.DatabaseErrorPageMiddleware_Exception)));
|
||||
m.StartsWith(StringsHelpers.GetResourceString("FormatDatabaseErrorPageMiddleware_Exception"))));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -334,10 +334,10 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
|||
}
|
||||
}
|
||||
|
||||
private static async Task<TestServer> SetupTestServer<TContext, TMiddleware>(ILoggerProvider logProvider = null)
|
||||
private static TestServer SetupTestServer<TContext, TMiddleware>(ILoggerProvider logProvider = null)
|
||||
where TContext : DbContext
|
||||
{
|
||||
using (var database = await SqlServerTestStore.CreateScratchAsync(createDatabase: false))
|
||||
using (var database = SqlServerTestStore.CreateScratch())
|
||||
{
|
||||
return TestServer.Create(app =>
|
||||
{
|
||||
|
|
@ -349,7 +349,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
|||
services.AddScoped<TContext>();
|
||||
services.AddInstance<DbContextOptions>(
|
||||
new DbContextOptions()
|
||||
.UseSqlServer(database.Connection.ConnectionString));
|
||||
.UseSqlServer(database.ConnectionString));
|
||||
});
|
||||
|
||||
app.UseDatabaseErrorPage();
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ using Microsoft.AspNet.TestHost;
|
|||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Data.Entity.Migrations.Infrastructure;
|
||||
using Microsoft.Data.Entity.Migrations.Utilities;
|
||||
using Microsoft.Data.Entity.SqlServer.FunctionalTests;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Xunit;
|
||||
using Microsoft.AspNet.Diagnostics.Entity.Tests.Helpers;
|
||||
|
||||
namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
||||
{
|
||||
|
|
@ -60,9 +60,9 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
|||
|
||||
private async Task Migration_request(bool useCustomPath)
|
||||
{
|
||||
using (var database = await SqlServerTestStore.CreateScratchAsync(createDatabase: false))
|
||||
using (var database = SqlServerTestStore.CreateScratch())
|
||||
{
|
||||
var options = new DbContextOptions().UseSqlServer(database.Connection.ConnectionString);
|
||||
var options = new DbContextOptions().UseSqlServer(database.ConnectionString);
|
||||
var path = useCustomPath ? new PathString("/EndPoints/ApplyMyMigrations") : MigrationsEndPointOptions.DefaultPath;
|
||||
|
||||
TestServer server = TestServer.Create(app =>
|
||||
|
|
@ -122,7 +122,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
|||
var content = await response.Content.ReadAsStringAsync();
|
||||
|
||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||
Assert.StartsWith(Strings.MigrationsEndPointMiddleware_NoContextType, content);
|
||||
Assert.StartsWith(StringsHelpers.GetResourceString("FormatMigrationsEndPointMiddleware_NoContextType"), content);
|
||||
Assert.True(content.Length > 512);
|
||||
}
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
|||
var content = await response.Content.ReadAsStringAsync();
|
||||
|
||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||
Assert.StartsWith(Strings.MigrationsEndPointMiddleware_InvalidContextType(typeName), content);
|
||||
Assert.StartsWith(StringsHelpers.GetResourceString("FormatMigrationsEndPointMiddleware_InvalidContextType", typeName), content);
|
||||
Assert.True(content.Length > 512);
|
||||
}
|
||||
|
||||
|
|
@ -169,16 +169,16 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
|||
var content = await response.Content.ReadAsStringAsync();
|
||||
|
||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||
Assert.StartsWith(Strings.MigrationsEndPointMiddleware_ContextNotRegistered(typeof(BloggingContext)), content);
|
||||
Assert.StartsWith(StringsHelpers.GetResourceString("FormatMigrationsEndPointMiddleware_ContextNotRegistered", typeof(BloggingContext)), content);
|
||||
Assert.True(content.Length > 512);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Exception_while_applying_migrations()
|
||||
{
|
||||
using (var database = await SqlServerTestStore.CreateScratchAsync(createDatabase: false))
|
||||
using (var database = SqlServerTestStore.CreateScratch())
|
||||
{
|
||||
var options = new DbContextOptions().UseSqlServer(database.Connection.ConnectionString);
|
||||
var options = new DbContextOptions().UseSqlServer(database.ConnectionString);
|
||||
|
||||
TestServer server = TestServer.Create(app =>
|
||||
{
|
||||
|
|
@ -200,7 +200,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
|||
var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () =>
|
||||
await server.CreateClient().PostAsync("http://localhost" + MigrationsEndPointOptions.DefaultPath, formData));
|
||||
|
||||
Assert.Equal(Strings.MigrationsEndPointMiddleware_Exception(typeof(BloggingContextWithSnapshotThatThrows)), ex.Message);
|
||||
Assert.Equal(StringsHelpers.GetResourceString("FormatMigrationsEndPointMiddleware_Exception", typeof(BloggingContextWithSnapshotThatThrows)), ex.Message);
|
||||
Assert.Equal("Welcome to the invalid snapshot!", ex.InnerException.Message);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. 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.Data.SqlClient;
|
||||
using System.Threading;
|
||||
using Microsoft.Data.Entity;
|
||||
|
||||
namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
||||
{
|
||||
public class SqlServerTestStore : IDisposable
|
||||
{
|
||||
private static int _scratchCount;
|
||||
|
||||
public static SqlServerTestStore CreateScratch()
|
||||
{
|
||||
var name = "Microsoft.AspNet.Diagnostics.Entity.FunctionalTests.Scratch_" + Interlocked.Increment(ref _scratchCount);
|
||||
var db = new SqlServerTestStore(name);
|
||||
db.EnsureDeleted();
|
||||
return db;
|
||||
}
|
||||
|
||||
private readonly string _connectionString;
|
||||
|
||||
private SqlServerTestStore(string name)
|
||||
{
|
||||
_connectionString = new SqlConnectionStringBuilder
|
||||
{
|
||||
DataSource = @"(localdb)\v11.0",
|
||||
InitialCatalog = name,
|
||||
IntegratedSecurity = true,
|
||||
ConnectTimeout = 30
|
||||
}.ConnectionString; ;
|
||||
}
|
||||
|
||||
public string ConnectionString
|
||||
{
|
||||
get { return _connectionString; }
|
||||
}
|
||||
|
||||
private void EnsureDeleted()
|
||||
{
|
||||
using (var db = new DbContext(new DbContextOptions().UseSqlServer(_connectionString)))
|
||||
{
|
||||
db.Database.EnsureDeleted();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
EnsureDeleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Data.Entity.Migrations.Infrastructure;
|
||||
using Microsoft.Data.Entity.SqlServer.FunctionalTests;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"EntityFramework.SqlServer": "7.0.0-*",
|
||||
"EntityFramework.SqlServer.FunctionalTests": "1.0.0",
|
||||
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-*",
|
||||
"Microsoft.AspNet.Diagnostics.Entity.Tests": "1.0.0",
|
||||
"Microsoft.AspNet.TestHost": "1.0.0-*",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,142 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. 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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.Data.Entity
|
||||
{
|
||||
public abstract class ApiConsistencyTestBase
|
||||
{
|
||||
protected const BindingFlags PublicInstance
|
||||
= BindingFlags.Instance | BindingFlags.Public;
|
||||
|
||||
protected const BindingFlags AnyInstance
|
||||
= BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
|
||||
|
||||
[Fact]
|
||||
public void Public_inheritable_apis_should_be_virtual()
|
||||
{
|
||||
var nonVirtualMethods
|
||||
= (from type in GetAllTypes(TargetAssembly.GetTypes())
|
||||
where type.IsVisible
|
||||
&& !type.IsSealed
|
||||
&& type.GetConstructors(AnyInstance).Any(c => c.IsPublic || c.IsFamily || c.IsFamilyOrAssembly)
|
||||
&& type.Namespace != null
|
||||
&& !type.Namespace.EndsWith(".Compiled")
|
||||
from method in type.GetMethods(PublicInstance)
|
||||
where method.DeclaringType == type
|
||||
&& !(method.IsVirtual && !method.IsFinal)
|
||||
select type.FullName + "." + method.Name)
|
||||
.ToList();
|
||||
|
||||
Assert.False(
|
||||
nonVirtualMethods.Any(),
|
||||
"\r\n-- Missing virtual APIs --\r\n" + string.Join("\r\n", nonVirtualMethods));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Public_api_arguments_should_have_not_null_annotation()
|
||||
{
|
||||
var parametersMissingAttribute
|
||||
= (from type in GetAllTypes(TargetAssembly.GetTypes())
|
||||
where type.IsVisible && !typeof(Delegate).IsAssignableFrom(type)
|
||||
let interfaceMappings = type.GetInterfaces().Select(type.GetInterfaceMap)
|
||||
let events = type.GetEvents()
|
||||
from method in type.GetMethods(PublicInstance | BindingFlags.Static)
|
||||
.Concat<MethodBase>(type.GetConstructors())
|
||||
where method.DeclaringType == type
|
||||
where type.IsInterface || !interfaceMappings.Any(im => im.TargetMethods.Contains(method))
|
||||
where !events.Any(e => e.AddMethod == method || e.RemoveMethod == method)
|
||||
from parameter in method.GetParameters()
|
||||
where !parameter.ParameterType.IsValueType
|
||||
&& !parameter.GetCustomAttributes()
|
||||
.Any(
|
||||
a => a.GetType().Name == "NotNullAttribute"
|
||||
|| a.GetType().Name == "CanBeNullAttribute")
|
||||
select type.FullName + "." + method.Name + "[" + parameter.Name + "]")
|
||||
.ToList();
|
||||
|
||||
Assert.False(
|
||||
parametersMissingAttribute.Any(),
|
||||
"\r\n-- Missing NotNull annotations --\r\n" + string.Join("\r\n", parametersMissingAttribute));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Async_methods_should_have_overload_with_cancellation_token_and_end_with_async_suffix()
|
||||
{
|
||||
var asyncMethods
|
||||
= (from type in GetAllTypes(TargetAssembly.GetTypes())
|
||||
where type.IsVisible
|
||||
from method in type.GetMethods(PublicInstance | BindingFlags.Static)
|
||||
where method.DeclaringType == type
|
||||
where typeof(Task).IsAssignableFrom(method.ReturnType)
|
||||
select method).ToList();
|
||||
|
||||
var asyncMethodsWithToken
|
||||
= (from method in asyncMethods
|
||||
where method.GetParameters().Any(pi => pi.ParameterType == typeof(CancellationToken))
|
||||
select method).ToList();
|
||||
|
||||
var asyncMethodsWithoutToken
|
||||
= (from method in asyncMethods
|
||||
where method.GetParameters().All(pi => pi.ParameterType != typeof(CancellationToken))
|
||||
select method).ToList();
|
||||
|
||||
var missingOverloads
|
||||
= (from methodWithoutToken in asyncMethodsWithoutToken
|
||||
where !asyncMethodsWithToken
|
||||
.Any(methodWithToken => methodWithoutToken.Name == methodWithToken.Name
|
||||
&& methodWithoutToken.ReflectedType == methodWithToken.ReflectedType)
|
||||
// ReSharper disable once PossibleNullReferenceException
|
||||
select methodWithoutToken.DeclaringType.Name + "." + methodWithoutToken.Name)
|
||||
.Except(GetCancellationTokenExceptions())
|
||||
.ToList();
|
||||
|
||||
Assert.False(
|
||||
missingOverloads.Any(),
|
||||
"\r\n-- Missing async overloads --\r\n" + string.Join("\r\n", missingOverloads));
|
||||
|
||||
var missingSuffixMethods
|
||||
= asyncMethods
|
||||
.Where(method => !method.Name.EndsWith("Async"))
|
||||
.Select(method => method.DeclaringType.Name + "." + method.Name)
|
||||
.Except(GetAsyncSuffixExceptions())
|
||||
.ToList();
|
||||
|
||||
Assert.False(
|
||||
missingSuffixMethods.Any(),
|
||||
"\r\n-- Missing async suffix --\r\n" + string.Join("\r\n", missingSuffixMethods));
|
||||
}
|
||||
|
||||
protected virtual IEnumerable<string> GetCancellationTokenExceptions()
|
||||
{
|
||||
return Enumerable.Empty<string>();
|
||||
}
|
||||
|
||||
protected virtual IEnumerable<string> GetAsyncSuffixExceptions()
|
||||
{
|
||||
return Enumerable.Empty<string>();
|
||||
}
|
||||
|
||||
protected abstract Assembly TargetAssembly { get; }
|
||||
|
||||
protected virtual IEnumerable<Type> GetAllTypes(IEnumerable<Type> types)
|
||||
{
|
||||
foreach (var type in types)
|
||||
{
|
||||
yield return type;
|
||||
|
||||
foreach (var nestedType in GetAllTypes(type.GetNestedTypes()))
|
||||
{
|
||||
yield return nestedType;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,32 +10,32 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests.Helpers
|
|||
{
|
||||
public static void DisplaysScaffoldFirstMigration(Type contextType, string content)
|
||||
{
|
||||
Assert.Contains(Strings.DatabaseErrorPage_NoDbOrMigrationsTitle(contextType.Name), content);
|
||||
Assert.Contains(StringsHelpers.GetResourceString("FormatDatabaseErrorPage_NoDbOrMigrationsTitle", contextType.Name), content);
|
||||
}
|
||||
|
||||
public static void NotDisplaysScaffoldFirstMigration(Type contextType, string content)
|
||||
{
|
||||
Assert.DoesNotContain(Strings.DatabaseErrorPage_NoDbOrMigrationsTitle(contextType.Name), content);
|
||||
Assert.DoesNotContain(StringsHelpers.GetResourceString("FormatDatabaseErrorPage_NoDbOrMigrationsTitle", contextType.Name), content);
|
||||
}
|
||||
|
||||
public static void DisplaysApplyMigrations(Type contextType, string content)
|
||||
{
|
||||
Assert.Contains(Strings.DatabaseErrorPage_PendingMigrationsTitle(contextType.Name), content);
|
||||
Assert.Contains(StringsHelpers.GetResourceString("FormatDatabaseErrorPage_PendingMigrationsTitle", contextType.Name), content);
|
||||
}
|
||||
|
||||
public static void NotDisplaysApplyMigrations(Type contextType, string content)
|
||||
{
|
||||
Assert.DoesNotContain(Strings.DatabaseErrorPage_PendingMigrationsTitle(contextType.Name), content);
|
||||
Assert.DoesNotContain(StringsHelpers.GetResourceString("FormatDatabaseErrorPage_PendingMigrationsTitle", contextType.Name), content);
|
||||
}
|
||||
|
||||
public static void DisplaysScaffoldNextMigraion(Type contextType, string content)
|
||||
{
|
||||
Assert.Contains(Strings.DatabaseErrorPage_PendingChangesTitle(contextType.Name), content);
|
||||
Assert.Contains(StringsHelpers.GetResourceString("FormatDatabaseErrorPage_PendingChangesTitle", contextType.Name), content);
|
||||
}
|
||||
|
||||
public static void NotDisplaysScaffoldNextMigraion(Type contextType, string content)
|
||||
{
|
||||
Assert.DoesNotContain(Strings.DatabaseErrorPage_PendingChangesTitle(contextType.Name), content);
|
||||
Assert.DoesNotContain(StringsHelpers.GetResourceString("FormatDatabaseErrorPage_PendingChangesTitle", contextType.Name), content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. 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.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Microsoft.AspNet.Diagnostics.Entity.Tests.Helpers
|
||||
{
|
||||
public class StringsHelpers
|
||||
{
|
||||
public static string GetResourceString(string stringName, params object[] parameters)
|
||||
{
|
||||
var strings = typeof(DatabaseErrorPageMiddleware).GetTypeInfo().Assembly.GetType("Microsoft.AspNet.Diagnostics.Entity.Strings").GetTypeInfo();
|
||||
var method = strings.GetDeclaredMethods(stringName).Single();
|
||||
return (string)method.Invoke(null, parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue