commit
bb408e9f18
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.Abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.Abstractions, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||||
"Types": [
|
"Types": [
|
||||||
{
|
{
|
||||||
"Name": "Microsoft.AspNetCore.Mvc.ActionContext",
|
"Name": "Microsoft.AspNetCore.Mvc.ActionContext",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.ApiExplorer, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.ApiExplorer, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||||
"Types": [
|
"Types": [
|
||||||
{
|
{
|
||||||
"Name": "Microsoft.AspNetCore.Mvc.ApiExplorer.ApiDescriptionExtensions",
|
"Name": "Microsoft.AspNetCore.Mvc.ApiExplorer.ApiDescriptionExtensions",
|
||||||
|
|
|
||||||
|
|
@ -19,27 +19,17 @@ namespace Microsoft.AspNetCore.Mvc.ApplicationParts
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class ApplicationPartFactory
|
public abstract class ApplicationPartFactory
|
||||||
{
|
{
|
||||||
public static readonly string DefaultContextName = "Default";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Default implementation for <see cref="ApplicationPartFactory"/>.
|
|
||||||
/// </summary>
|
|
||||||
public static ApplicationPartFactory Default { get; } = new DefaultApplicationPartFactory();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets one or more <see cref="ApplicationPart"/> instances for the specified <paramref name="assembly"/>.
|
/// Gets one or more <see cref="ApplicationPart"/> instances for the specified <paramref name="assembly"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assembly">The <see cref="Assembly"/>.</param>
|
/// <param name="assembly">The <see cref="Assembly"/>.</param>
|
||||||
/// <param name="context">
|
public abstract IEnumerable<ApplicationPart> GetApplicationParts(Assembly assembly);
|
||||||
/// The context name. By default, value of this parameter is <see cref="DefaultContextName"/>.
|
|
||||||
/// </param>
|
|
||||||
public abstract IEnumerable<ApplicationPart> GetApplicationParts(Assembly assembly, string context);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the <see cref="ApplicationPartFactory"/> for the specified assembly.
|
/// Gets the <see cref="ApplicationPartFactory"/> for the specified assembly.
|
||||||
/// <para>
|
/// <para>
|
||||||
/// An assembly may specify an <see cref="ApplicationPartFactory"/> using <see cref="ProvideApplicationPartFactoryAttribute"/>.
|
/// An assembly may specify an <see cref="ApplicationPartFactory"/> using <see cref="ProvideApplicationPartFactoryAttribute"/>.
|
||||||
/// Otherwise, <see cref="ApplicationPartFactory.Default"/> is used.
|
/// Otherwise, <see cref="DefaultApplicationPartFactory"/> is used.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assembly">The <see cref="Assembly"/>.</param>
|
/// <param name="assembly">The <see cref="Assembly"/>.</param>
|
||||||
|
|
@ -54,7 +44,7 @@ namespace Microsoft.AspNetCore.Mvc.ApplicationParts
|
||||||
var provideAttribute = assembly.GetCustomAttribute<ProvideApplicationPartFactoryAttribute>();
|
var provideAttribute = assembly.GetCustomAttribute<ProvideApplicationPartFactoryAttribute>();
|
||||||
if (provideAttribute == null)
|
if (provideAttribute == null)
|
||||||
{
|
{
|
||||||
return ApplicationPartFactory.Default;
|
return DefaultApplicationPartFactory.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
var type = provideAttribute.GetFactoryType();
|
var type = provideAttribute.GetFactoryType();
|
||||||
|
|
@ -68,18 +58,5 @@ namespace Microsoft.AspNetCore.Mvc.ApplicationParts
|
||||||
|
|
||||||
return (ApplicationPartFactory)Activator.CreateInstance(type);
|
return (ApplicationPartFactory)Activator.CreateInstance(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DefaultApplicationPartFactory : ApplicationPartFactory
|
|
||||||
{
|
|
||||||
public override IEnumerable<ApplicationPart> GetApplicationParts(Assembly assembly, string context)
|
|
||||||
{
|
|
||||||
if (assembly == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(assembly));
|
|
||||||
}
|
|
||||||
|
|
||||||
yield return new AssemblyPart(assembly);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ namespace Microsoft.AspNetCore.Mvc.ApplicationParts
|
||||||
foreach (var assembly in applicationAssemblies)
|
foreach (var assembly in applicationAssemblies)
|
||||||
{
|
{
|
||||||
var partFactory = ApplicationPartFactory.GetApplicationPartFactory(assembly);
|
var partFactory = ApplicationPartFactory.GetApplicationPartFactory(assembly);
|
||||||
foreach (var part in partFactory.GetApplicationParts(assembly, context: ApplicationPartFactory.DefaultContextName))
|
foreach (var part in partFactory.GetApplicationParts(assembly))
|
||||||
{
|
{
|
||||||
ApplicationParts.Add(part);
|
ApplicationParts.Add(part);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Mvc.ApplicationParts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Default <see cref="ApplicationPartFactory"/>.
|
||||||
|
/// </summary>
|
||||||
|
public class DefaultApplicationPartFactory : ApplicationPartFactory
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets an instance of <see cref="DefaultApplicationPartFactory"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static DefaultApplicationPartFactory Instance { get; } = new DefaultApplicationPartFactory();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the sequence of <see cref="ApplicationPart"/> instances that are created by this instance of <see cref="DefaultApplicationPartFactory"/>.
|
||||||
|
/// <para>
|
||||||
|
/// Applications may use this method to get the same behavior as this factory produces during MVC's default part discovery.
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assembly">The <see cref="Assembly"/>.</param>
|
||||||
|
/// <returns>The sequence of <see cref="ApplicationPart"/> instances.</returns>
|
||||||
|
public static IEnumerable<ApplicationPart> GetDefaultApplicationParts(Assembly assembly)
|
||||||
|
{
|
||||||
|
if (assembly == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(assembly));
|
||||||
|
}
|
||||||
|
|
||||||
|
yield return new AssemblyPart(assembly);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override IEnumerable<ApplicationPart> GetApplicationParts(Assembly assembly)
|
||||||
|
{
|
||||||
|
return GetDefaultApplicationParts(assembly);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.Mvc.ApplicationParts
|
||||||
public class NullApplicationPartFactory : ApplicationPartFactory
|
public class NullApplicationPartFactory : ApplicationPartFactory
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override IEnumerable<ApplicationPart> GetApplicationParts(Assembly assembly, string context)
|
public override IEnumerable<ApplicationPart> GetApplicationParts(Assembly assembly)
|
||||||
{
|
{
|
||||||
return Enumerable.Empty<ApplicationPart>();
|
return Enumerable.Empty<ApplicationPart>();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,14 @@ namespace Microsoft.AspNetCore.Mvc.ApplicationParts
|
||||||
throw new ArgumentNullException(nameof(assembly));
|
throw new ArgumentNullException(nameof(assembly));
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetRelatedAssemblies(assembly, throwOnError, AssemblyLoadFileDelegate);
|
return GetRelatedAssemblies(assembly, throwOnError, File.Exists, AssemblyLoadFileDelegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static IReadOnlyList<Assembly> GetRelatedAssemblies(Assembly assembly, bool throwOnError, Func<string, Assembly> loadFile)
|
internal static IReadOnlyList<Assembly> GetRelatedAssemblies(
|
||||||
|
Assembly assembly,
|
||||||
|
bool throwOnError,
|
||||||
|
Func<string, bool> fileExists,
|
||||||
|
Func<string, Assembly> loadFile)
|
||||||
{
|
{
|
||||||
if (assembly == null)
|
if (assembly == null)
|
||||||
{
|
{
|
||||||
|
|
@ -74,7 +78,8 @@ namespace Microsoft.AspNetCore.Mvc.ApplicationParts
|
||||||
}
|
}
|
||||||
|
|
||||||
var assemblyName = assembly.GetName().Name;
|
var assemblyName = assembly.GetName().Name;
|
||||||
var assemblyDirectory = Path.GetDirectoryName(assembly.CodeBase);
|
var assemblyLocation = GetAssemblyLocation(assembly);
|
||||||
|
var assemblyDirectory = Path.GetDirectoryName(assemblyLocation);
|
||||||
|
|
||||||
var relatedAssemblies = new List<Assembly>();
|
var relatedAssemblies = new List<Assembly>();
|
||||||
for (var i = 0; i < attributes.Length; i++)
|
for (var i = 0; i < attributes.Length; i++)
|
||||||
|
|
@ -87,7 +92,7 @@ namespace Microsoft.AspNetCore.Mvc.ApplicationParts
|
||||||
}
|
}
|
||||||
|
|
||||||
var relatedAssemblyLocation = Path.Combine(assemblyDirectory, attribute.AssemblyFileName + ".dll");
|
var relatedAssemblyLocation = Path.Combine(assemblyDirectory, attribute.AssemblyFileName + ".dll");
|
||||||
if (!File.Exists(relatedAssemblyLocation))
|
if (!fileExists(relatedAssemblyLocation))
|
||||||
{
|
{
|
||||||
if (throwOnError)
|
if (throwOnError)
|
||||||
{
|
{
|
||||||
|
|
@ -107,5 +112,15 @@ namespace Microsoft.AspNetCore.Mvc.ApplicationParts
|
||||||
|
|
||||||
return relatedAssemblies;
|
return relatedAssemblies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static string GetAssemblyLocation(Assembly assembly)
|
||||||
|
{
|
||||||
|
if (Uri.TryCreate(assembly.CodeBase, UriKind.Absolute, out var result) && result.IsFile)
|
||||||
|
{
|
||||||
|
return result.LocalPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
return assembly.Location;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.Core, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||||
"Types": [
|
"Types": [
|
||||||
{
|
{
|
||||||
"Name": "Microsoft.AspNetCore.Builder.MvcApplicationBuilderExtensions",
|
"Name": "Microsoft.AspNetCore.Builder.MvcApplicationBuilderExtensions",
|
||||||
|
|
@ -19488,6 +19488,11 @@
|
||||||
"Name": "etag",
|
"Name": "etag",
|
||||||
"Type": "Microsoft.Net.Http.Headers.EntityTagHeaderValue",
|
"Type": "Microsoft.Net.Http.Headers.EntityTagHeaderValue",
|
||||||
"DefaultValue": "null"
|
"DefaultValue": "null"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "enableRangeProcessing",
|
||||||
|
"Type": "System.Boolean",
|
||||||
|
"DefaultValue": "True"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"ReturnType": "System.ValueTuple<Microsoft.Net.Http.Headers.RangeItemHeaderValue, System.Int64, System.Boolean>",
|
"ReturnType": "System.ValueTuple<Microsoft.Net.Http.Headers.RangeItemHeaderValue, System.Int64, System.Boolean>",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.Cors, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.Cors, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||||
"Types": [
|
"Types": [
|
||||||
{
|
{
|
||||||
"Name": "Microsoft.Extensions.DependencyInjection.MvcCorsMvcCoreBuilderExtensions",
|
"Name": "Microsoft.Extensions.DependencyInjection.MvcCorsMvcCoreBuilderExtensions",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.DataAnnotations, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.DataAnnotations, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||||
"Types": [
|
"Types": [
|
||||||
{
|
{
|
||||||
"Name": "Microsoft.AspNetCore.Mvc.HiddenInputAttribute",
|
"Name": "Microsoft.AspNetCore.Mvc.HiddenInputAttribute",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.Formatters.Json, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.Formatters.Json, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||||
"Types": [
|
"Types": [
|
||||||
{
|
{
|
||||||
"Name": "Microsoft.AspNetCore.Mvc.JsonPatchExtensions",
|
"Name": "Microsoft.AspNetCore.Mvc.JsonPatchExtensions",
|
||||||
|
|
@ -366,6 +366,14 @@
|
||||||
"Visibility": "Protected",
|
"Visibility": "Protected",
|
||||||
"GenericParameter": []
|
"GenericParameter": []
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"Kind": "Method",
|
||||||
|
"Name": "get_PublicSerializerSettings",
|
||||||
|
"Parameters": [],
|
||||||
|
"ReturnType": "Newtonsoft.Json.JsonSerializerSettings",
|
||||||
|
"Visibility": "Public",
|
||||||
|
"GenericParameter": []
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"Kind": "Method",
|
"Kind": "Method",
|
||||||
"Name": "WriteObject",
|
"Name": "WriteObject",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.Formatters.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.Formatters.Xml, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||||
"Types": [
|
"Types": [
|
||||||
{
|
{
|
||||||
"Name": "Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DataMemberRequiredBindingMetadataProvider",
|
"Name": "Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DataMemberRequiredBindingMetadataProvider",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.Localization, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.Localization, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||||
"Types": [
|
"Types": [
|
||||||
{
|
{
|
||||||
"Name": "Microsoft.AspNetCore.Mvc.Localization.HtmlLocalizer",
|
"Name": "Microsoft.AspNetCore.Mvc.Localization.HtmlLocalizer",
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,15 @@ namespace Microsoft.AspNetCore.Mvc.ApplicationParts
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CompiledRazorAssemblyApplicationPartFactory : ApplicationPartFactory
|
public class CompiledRazorAssemblyApplicationPartFactory : ApplicationPartFactory
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <summary>
|
||||||
public override IEnumerable<ApplicationPart> GetApplicationParts(Assembly assembly, string configuration)
|
/// Gets the sequence of <see cref="ApplicationPart"/> instances that are created by this instance of <see cref="DefaultApplicationPartFactory"/>.
|
||||||
|
/// <para>
|
||||||
|
/// Applications may use this method to get the same behavior as this factory produces during MVC's default part discovery.
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assembly">The <see cref="Assembly"/>.</param>
|
||||||
|
/// <returns>The sequence of <see cref="ApplicationPart"/> instances.</returns>
|
||||||
|
public static IEnumerable<ApplicationPart> GetDefaultApplicationParts(Assembly assembly)
|
||||||
{
|
{
|
||||||
if (assembly == null)
|
if (assembly == null)
|
||||||
{
|
{
|
||||||
|
|
@ -22,5 +29,8 @@ namespace Microsoft.AspNetCore.Mvc.ApplicationParts
|
||||||
|
|
||||||
yield return new CompiledRazorAssemblyPart(assembly);
|
yield return new CompiledRazorAssemblyPart(assembly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override IEnumerable<ApplicationPart> GetApplicationParts(Assembly assembly) => GetDefaultApplicationParts(assembly);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.Razor, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||||
"Types": [
|
"Types": [
|
||||||
{
|
{
|
||||||
"Name": "Microsoft.AspNetCore.Mvc.Razor.HelperResult",
|
"Name": "Microsoft.AspNetCore.Mvc.Razor.HelperResult",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.RazorPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.RazorPages, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||||
"Types": [
|
"Types": [
|
||||||
{
|
{
|
||||||
"Name": "Microsoft.AspNetCore.Mvc.Internal.MvcRazorPagesDiagnosticSourceExtensions",
|
"Name": "Microsoft.AspNetCore.Mvc.Internal.MvcRazorPagesDiagnosticSourceExtensions",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.TagHelpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.TagHelpers, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||||
"Types": [
|
"Types": [
|
||||||
{
|
{
|
||||||
"Name": "Microsoft.AspNetCore.Mvc.Rendering.ValidationSummary",
|
"Name": "Microsoft.AspNetCore.Mvc.Rendering.ValidationSummary",
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1 @@
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.ViewFeatures, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.ViewFeatures, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||||
"Types": [
|
"Types": [
|
||||||
{
|
{
|
||||||
"Name": "Microsoft.AspNetCore.Mvc.AutoValidateAntiforgeryTokenAttribute",
|
"Name": "Microsoft.AspNetCore.Mvc.AutoValidateAntiforgeryTokenAttribute",
|
||||||
|
|
@ -17816,7 +17816,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Kind": "Method",
|
"Kind": "Method",
|
||||||
"Name": "DateTimeInputTemplate",
|
"Name": "DateTimeOffsetTemplate",
|
||||||
"Parameters": [
|
"Parameters": [
|
||||||
{
|
{
|
||||||
"Name": "htmlHelper",
|
"Name": "htmlHelper",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.WebApiCompatShim, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc.WebApiCompatShim, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||||
"Types": [
|
"Types": [
|
||||||
{
|
{
|
||||||
"Name": "System.Net.Http.HttpRequestMessageExtensions",
|
"Name": "System.Net.Http.HttpRequestMessageExtensions",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
"AssemblyIdentity": "Microsoft.AspNetCore.Mvc, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||||
"Types": [
|
"Types": [
|
||||||
{
|
{
|
||||||
"Name": "Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions",
|
"Name": "Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions",
|
||||||
|
|
|
||||||
|
|
@ -67,20 +67,46 @@ namespace Microsoft.AspNetCore.Mvc.ApplicationParts
|
||||||
};
|
};
|
||||||
var relatedAssembly = typeof(RelatedAssemblyPartTest).Assembly;
|
var relatedAssembly = typeof(RelatedAssemblyPartTest).Assembly;
|
||||||
|
|
||||||
try
|
var result = RelatedAssemblyAttribute.GetRelatedAssemblies(assembly, throwOnError: true, file => true, file =>
|
||||||
{
|
{
|
||||||
File.WriteAllBytes(destination, new byte[0]);
|
Assert.Equal(file, destination);
|
||||||
var result = RelatedAssemblyAttribute.GetRelatedAssemblies(assembly, throwOnError: true, file =>
|
return relatedAssembly;
|
||||||
{
|
});
|
||||||
Assert.Equal(file, destination);
|
Assert.Equal(new[] { relatedAssembly }, result);
|
||||||
return relatedAssembly;
|
}
|
||||||
});
|
|
||||||
Assert.Equal(new[] { relatedAssembly }, result);
|
[Fact]
|
||||||
}
|
public void GetAssemblyLocation_UsesCodeBase()
|
||||||
finally
|
{
|
||||||
|
// Arrange
|
||||||
|
var destination = Path.Combine(AssemblyDirectory, "RelatedAssembly.dll");
|
||||||
|
var codeBase = "file://x/file/Assembly.dll";
|
||||||
|
var expected = new Uri(codeBase).LocalPath;
|
||||||
|
var assembly = new TestAssembly
|
||||||
{
|
{
|
||||||
File.Delete(destination);
|
CodeBaseSettable = codeBase,
|
||||||
}
|
};
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var actual = RelatedAssemblyAttribute.GetAssemblyLocation(assembly);
|
||||||
|
Assert.Equal(expected, actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GetAssemblyLocation_UsesLocation_IfCodeBaseIsNotLocal()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var destination = Path.Combine(AssemblyDirectory, "RelatedAssembly.dll");
|
||||||
|
var expected = Path.Combine(AssemblyDirectory, "Some-Dir", "Assembly.dll");
|
||||||
|
var assembly = new TestAssembly
|
||||||
|
{
|
||||||
|
CodeBaseSettable = "https://www.microsoft.com/test.dll",
|
||||||
|
LocationSettable = expected,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var actual = RelatedAssemblyAttribute.GetAssemblyLocation(assembly);
|
||||||
|
Assert.Equal(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestAssembly : Assembly
|
private class TestAssembly : Assembly
|
||||||
|
|
@ -92,7 +118,13 @@ namespace Microsoft.AspNetCore.Mvc.ApplicationParts
|
||||||
|
|
||||||
public string AttributeAssembly { get; set; }
|
public string AttributeAssembly { get; set; }
|
||||||
|
|
||||||
public override string CodeBase => Path.Combine(AssemblyDirectory, "MyAssembly.dll");
|
public string CodeBaseSettable { get; set; } = Path.Combine(AssemblyDirectory, "MyAssembly.dll");
|
||||||
|
|
||||||
|
public override string CodeBase => CodeBaseSettable;
|
||||||
|
|
||||||
|
public string LocationSettable { get; set; } = Path.Combine(AssemblyDirectory, "MyAssembly.dll");
|
||||||
|
|
||||||
|
public override string Location => LocationSettable;
|
||||||
|
|
||||||
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
|
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue