Skip to content

Commit

Permalink
[main] Update dependencies from dotnet/runtime (#24861)
Browse files Browse the repository at this point in the history
[main] Update dependencies from dotnet/runtime


 - Workaround reflection bug in OData

OData was locating ServiceCollectionContainerBuilderExtensions in the same assembly as ServiceCollection.

This broke when ServiceCollection was pushed down to another assembly.

This works around it by avoiding reflection and directly calling
ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(this IServiceCollection).

This commit can be reverted when picking up an OData package with
OData/WebApi@1528766

 - Update dependencies from dotnet/runtime manually

'6.0.0-preview.5.21260.6' => '6.0.0-preview.5.21263.7' (from build '20210513.7' of 'https://github.com/dotnet/runtime')
  • Loading branch information
dotnet-maestro[bot] committed May 14, 2021
1 parent 14da5d9 commit d277e0c
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 42 deletions.
56 changes: 28 additions & 28 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.Extensions.Caching.Memory" Version="6.0.0-preview.5.21226.1">
<Dependency Name="Microsoft.Extensions.Caching.Memory" Version="6.0.0-preview.5.21263.7">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>3782e6e41cfaf76ec9ae4117722f835596026b1a</Sha>
<Sha>834f791688df21c4c3cbadc1a2a964b03d38188d</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.0-preview.5.21226.1">
<Dependency Name="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.0-preview.5.21263.7">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>3782e6e41cfaf76ec9ae4117722f835596026b1a</Sha>
<Sha>834f791688df21c4c3cbadc1a2a964b03d38188d</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0-preview.5.21226.1">
<Dependency Name="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0-preview.5.21263.7">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>3782e6e41cfaf76ec9ae4117722f835596026b1a</Sha>
<Sha>834f791688df21c4c3cbadc1a2a964b03d38188d</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Configuration.Json" Version="6.0.0-preview.5.21226.1">
<Dependency Name="Microsoft.Extensions.Configuration.Json" Version="6.0.0-preview.5.21263.7">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>3782e6e41cfaf76ec9ae4117722f835596026b1a</Sha>
<Sha>834f791688df21c4c3cbadc1a2a964b03d38188d</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Configuration" Version="6.0.0-preview.5.21226.1">
<Dependency Name="Microsoft.Extensions.Configuration" Version="6.0.0-preview.5.21263.7">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>3782e6e41cfaf76ec9ae4117722f835596026b1a</Sha>
<Sha>834f791688df21c4c3cbadc1a2a964b03d38188d</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.DependencyInjection" Version="6.0.0-preview.5.21226.1">
<Dependency Name="Microsoft.Extensions.DependencyInjection" Version="6.0.0-preview.5.21263.7">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>3782e6e41cfaf76ec9ae4117722f835596026b1a</Sha>
<Sha>834f791688df21c4c3cbadc1a2a964b03d38188d</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.DependencyModel" Version="6.0.0-preview.5.21226.1">
<Dependency Name="Microsoft.Extensions.DependencyModel" Version="6.0.0-preview.5.21263.7">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>3782e6e41cfaf76ec9ae4117722f835596026b1a</Sha>
<Sha>834f791688df21c4c3cbadc1a2a964b03d38188d</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.HostFactoryResolver.Sources" Version="6.0.0-preview.5.21226.1">
<Dependency Name="Microsoft.Extensions.HostFactoryResolver.Sources" Version="6.0.0-preview.5.21263.7">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>3782e6e41cfaf76ec9ae4117722f835596026b1a</Sha>
<Sha>834f791688df21c4c3cbadc1a2a964b03d38188d</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Logging" Version="6.0.0-preview.5.21226.1">
<Dependency Name="Microsoft.Extensions.Logging" Version="6.0.0-preview.5.21263.7">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>3782e6e41cfaf76ec9ae4117722f835596026b1a</Sha>
<Sha>834f791688df21c4c3cbadc1a2a964b03d38188d</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.App.Ref" Version="6.0.0-preview.5.21226.1">
<Dependency Name="Microsoft.NETCore.App.Ref" Version="6.0.0-preview.5.21263.7">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>3782e6e41cfaf76ec9ae4117722f835596026b1a</Sha>
<Sha>834f791688df21c4c3cbadc1a2a964b03d38188d</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="6.0.0-preview.5.21226.1">
<Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="6.0.0-preview.5.21263.7">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>3782e6e41cfaf76ec9ae4117722f835596026b1a</Sha>
<Sha>834f791688df21c4c3cbadc1a2a964b03d38188d</Sha>
</Dependency>
<!-- NB: Using BrowserDebugHost to represent the nonshipping version of Microsoft.NETCore.App -->
<Dependency Name="Microsoft.NETCore.BrowserDebugHost.Transport" Version="6.0.0-preview.5.21226.1">
<Dependency Name="Microsoft.NETCore.BrowserDebugHost.Transport" Version="6.0.0-preview.5.21263.7">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>3782e6e41cfaf76ec9ae4117722f835596026b1a</Sha>
<Sha>834f791688df21c4c3cbadc1a2a964b03d38188d</Sha>
</Dependency>
<Dependency Name="System.Collections.Immutable" Version="6.0.0-preview.5.21226.1">
<Dependency Name="System.Collections.Immutable" Version="6.0.0-preview.5.21263.7">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>3782e6e41cfaf76ec9ae4117722f835596026b1a</Sha>
<Sha>834f791688df21c4c3cbadc1a2a964b03d38188d</Sha>
</Dependency>
<Dependency Name="System.ComponentModel.Annotations" Version="6.0.0-preview.5.21226.1">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>3782e6e41cfaf76ec9ae4117722f835596026b1a</Sha>
</Dependency>
<Dependency Name="System.Diagnostics.DiagnosticSource" Version="6.0.0-preview.5.21226.1">
<Dependency Name="System.Diagnostics.DiagnosticSource" Version="6.0.0-preview.5.21263.7">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>3782e6e41cfaf76ec9ae4117722f835596026b1a</Sha>
<Sha>834f791688df21c4c3cbadc1a2a964b03d38188d</Sha>
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
Expand Down
28 changes: 14 additions & 14 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
<UsingToolXliff>False</UsingToolXliff>
</PropertyGroup>
<PropertyGroup Label="Dependencies from dotnet/runtime">
<SystemCollectionsImmutableVersion>6.0.0-preview.5.21226.1</SystemCollectionsImmutableVersion>
<SystemCollectionsImmutableVersion>6.0.0-preview.5.21263.7</SystemCollectionsImmutableVersion>
<SystemComponentModelAnnotationsVersion>6.0.0-preview.5.21226.1</SystemComponentModelAnnotationsVersion>
<SystemDiagnosticsDiagnosticSourceVersion>6.0.0-preview.5.21226.1</SystemDiagnosticsDiagnosticSourceVersion>
<MicrosoftExtensionsCachingMemoryVersion>6.0.0-preview.5.21226.1</MicrosoftExtensionsCachingMemoryVersion>
<MicrosoftExtensionsConfigurationVersion>6.0.0-preview.5.21226.1</MicrosoftExtensionsConfigurationVersion>
<MicrosoftExtensionsConfigurationAbstractionsVersion>6.0.0-preview.5.21226.1</MicrosoftExtensionsConfigurationAbstractionsVersion>
<MicrosoftExtensionsConfigurationEnvironmentVariablesVersion>6.0.0-preview.5.21226.1</MicrosoftExtensionsConfigurationEnvironmentVariablesVersion>
<MicrosoftExtensionsConfigurationJsonVersion>6.0.0-preview.5.21226.1</MicrosoftExtensionsConfigurationJsonVersion>
<MicrosoftExtensionsDependencyInjectionVersion>6.0.0-preview.5.21226.1</MicrosoftExtensionsDependencyInjectionVersion>
<MicrosoftExtensionsDependencyModelVersion>6.0.0-preview.5.21226.1</MicrosoftExtensionsDependencyModelVersion>
<MicrosoftExtensionsHostFactoryResolverSourcesVersion>6.0.0-preview.5.21226.1</MicrosoftExtensionsHostFactoryResolverSourcesVersion>
<MicrosoftExtensionsLoggingVersion>6.0.0-preview.5.21226.1</MicrosoftExtensionsLoggingVersion>
<MicrosoftNETCoreAppRefVersion>6.0.0-preview.5.21226.1</MicrosoftNETCoreAppRefVersion>
<MicrosoftNETCoreAppRuntimewinx64Version>6.0.0-preview.5.21226.1</MicrosoftNETCoreAppRuntimewinx64Version>
<MicrosoftNETCoreBrowserDebugHostTransportVersion>6.0.0-preview.5.21226.1</MicrosoftNETCoreBrowserDebugHostTransportVersion>
<SystemDiagnosticsDiagnosticSourceVersion>6.0.0-preview.5.21263.7</SystemDiagnosticsDiagnosticSourceVersion>
<MicrosoftExtensionsCachingMemoryVersion>6.0.0-preview.5.21263.7</MicrosoftExtensionsCachingMemoryVersion>
<MicrosoftExtensionsConfigurationVersion>6.0.0-preview.5.21263.7</MicrosoftExtensionsConfigurationVersion>
<MicrosoftExtensionsConfigurationAbstractionsVersion>6.0.0-preview.5.21263.7</MicrosoftExtensionsConfigurationAbstractionsVersion>
<MicrosoftExtensionsConfigurationEnvironmentVariablesVersion>6.0.0-preview.5.21263.7</MicrosoftExtensionsConfigurationEnvironmentVariablesVersion>
<MicrosoftExtensionsConfigurationJsonVersion>6.0.0-preview.5.21263.7</MicrosoftExtensionsConfigurationJsonVersion>
<MicrosoftExtensionsDependencyInjectionVersion>6.0.0-preview.5.21263.7</MicrosoftExtensionsDependencyInjectionVersion>
<MicrosoftExtensionsDependencyModelVersion>6.0.0-preview.5.21263.7</MicrosoftExtensionsDependencyModelVersion>
<MicrosoftExtensionsHostFactoryResolverSourcesVersion>6.0.0-preview.5.21263.7</MicrosoftExtensionsHostFactoryResolverSourcesVersion>
<MicrosoftExtensionsLoggingVersion>6.0.0-preview.5.21263.7</MicrosoftExtensionsLoggingVersion>
<MicrosoftNETCoreAppRefVersion>6.0.0-preview.5.21263.7</MicrosoftNETCoreAppRefVersion>
<MicrosoftNETCoreAppRuntimewinx64Version>6.0.0-preview.5.21263.7</MicrosoftNETCoreAppRuntimewinx64Version>
<MicrosoftNETCoreBrowserDebugHostTransportVersion>6.0.0-preview.5.21263.7</MicrosoftNETCoreBrowserDebugHostTransportVersion>
</PropertyGroup>
<PropertyGroup Label="Other dependencies">
<MicrosoftCodeAnalysisVersion>3.7.0</MicrosoftCodeAnalysisVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// 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.Linq;
using System.Net;
Expand All @@ -20,6 +21,7 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.OData.Edm;
using Microsoft.AspNet.OData;

namespace Microsoft.EntityFrameworkCore.Query
{
Expand Down Expand Up @@ -58,6 +60,13 @@ public static (string BaseAddress, IHttpClientFactory ClientFactory, IHost SelfH
}
}
IPerRouteContainer perRouteContainer = endpoints.ServiceProvider.GetRequiredService<IPerRouteContainer>();
if (perRouteContainer == null)
{
throw new InvalidOperationException($"Could not resolve {nameof(IPerRouteContainer)}.");
}
perRouteContainer.BuilderFactory = () => new WorkaroundContainerBuilder();
endpoints.MaxTop(null).Expand().Select().OrderBy().Filter().Count();
endpoints.MapODataRoute("odata", "odata",
edmModel,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OData;

namespace Microsoft.AspNet.OData
{
// This is a copy of https://github.com/OData/WebApi/blob/757631faf10b494e55117904196e8aa45d4c764d/src/Microsoft.AspNet.OData.Shared/DefaultContainerBuilder.cs
// with a fix for reflection issue in BuildContainer
// This can be removed once an OData package is available with https://github.com/OData/WebApi/commit/1528766b49b8dd49dd8845d8ea5e2973268eeee4
public class WorkaroundContainerBuilder : IContainerBuilder
{
private readonly IServiceCollection services = new ServiceCollection();

public virtual IContainerBuilder AddService(Microsoft.OData.ServiceLifetime lifetime, Type serviceType,Type implementationType)
{
services.Add(new ServiceDescriptor(
serviceType ?? throw new ArgumentNullException(nameof(serviceType)),
implementationType ?? throw new ArgumentNullException(nameof(implementationType)),
TranslateServiceLifetime(lifetime)));

return this;
}

public IContainerBuilder AddService(Microsoft.OData.ServiceLifetime lifetime, Type serviceType, Func<IServiceProvider, object> implementationFactory)
{
services.Add(new ServiceDescriptor(
serviceType ?? throw new ArgumentNullException(nameof(serviceType)),
implementationFactory ?? throw new ArgumentNullException(nameof(implementationFactory)),
TranslateServiceLifetime(lifetime)));

return this;
}

public virtual IServiceProvider BuildContainer() => services.BuildServiceProvider(); // workaround is here, don't use reflection to call BuildServiceProvider

private static Microsoft.Extensions.DependencyInjection.ServiceLifetime TranslateServiceLifetime(Microsoft.OData.ServiceLifetime lifetime) => lifetime switch
{
Microsoft.OData.ServiceLifetime.Scoped => Microsoft.Extensions.DependencyInjection.ServiceLifetime.Scoped,
Microsoft.OData.ServiceLifetime.Singleton => Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton,
_ => Microsoft.Extensions.DependencyInjection.ServiceLifetime.Transient
};
}
}

0 comments on commit d277e0c

Please sign in to comment.