Skip to content

Commit

Permalink
Merge branch 'release/3.1' into merge/release/3.0-to-release/3.1
Browse files Browse the repository at this point in the history
Commit migrated from dotnet/extensions@f0027c4
  • Loading branch information
pranavkm committed Sep 10, 2019
2 parents 9fc548b + a4f3167 commit e5d3ea0
Show file tree
Hide file tree
Showing 20 changed files with 437 additions and 358 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- This file is automatically generated. -->
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0;netstandard2.0;netstandard2.1</TargetFrameworks>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<Compile Include="Microsoft.Extensions.DependencyInjection.netcoreapp3.0.cs" />
Expand All @@ -10,5 +10,10 @@
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<Compile Include="Microsoft.Extensions.DependencyInjection.netstandard2.0.cs" />
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<Reference Include="Microsoft.Bcl.AsyncInterfaces" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
<Compile Include="Microsoft.Extensions.DependencyInjection.netstandard2.1.cs" />
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ public static partial class ServiceCollectionContainerBuilderExtensions
public static Microsoft.Extensions.DependencyInjection.ServiceProvider BuildServiceProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Microsoft.Extensions.DependencyInjection.ServiceProviderOptions options) { throw null; }
public static Microsoft.Extensions.DependencyInjection.ServiceProvider BuildServiceProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, bool validateScopes) { throw null; }
}
public sealed partial class ServiceProvider : System.IDisposable, System.IServiceProvider
public sealed partial class ServiceProvider : System.IAsyncDisposable, System.IDisposable, System.IServiceProvider
{
internal ServiceProvider() { }
public void Dispose() { }
public System.Threading.Tasks.ValueTask DisposeAsync() { throw null; }
public object GetService(System.Type serviceType) { throw null; }
}
public partial class ServiceProviderOptions
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// 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.

namespace Microsoft.Extensions.DependencyInjection
{
public partial class DefaultServiceProviderFactory : Microsoft.Extensions.DependencyInjection.IServiceProviderFactory<Microsoft.Extensions.DependencyInjection.IServiceCollection>
{
public DefaultServiceProviderFactory() { }
public DefaultServiceProviderFactory(Microsoft.Extensions.DependencyInjection.ServiceProviderOptions options) { }
public Microsoft.Extensions.DependencyInjection.IServiceCollection CreateBuilder(Microsoft.Extensions.DependencyInjection.IServiceCollection services) { throw null; }
public System.IServiceProvider CreateServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection containerBuilder) { throw null; }
}
public partial class ServiceCollection : Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Collections.Generic.ICollection<Microsoft.Extensions.DependencyInjection.ServiceDescriptor>, System.Collections.Generic.IEnumerable<Microsoft.Extensions.DependencyInjection.ServiceDescriptor>, System.Collections.Generic.IList<Microsoft.Extensions.DependencyInjection.ServiceDescriptor>, System.Collections.IEnumerable
{
public ServiceCollection() { }
public int Count { get { throw null; } }
public bool IsReadOnly { get { throw null; } }
public Microsoft.Extensions.DependencyInjection.ServiceDescriptor this[int index] { get { throw null; } set { } }
public void Clear() { }
public bool Contains(Microsoft.Extensions.DependencyInjection.ServiceDescriptor item) { throw null; }
public void CopyTo(Microsoft.Extensions.DependencyInjection.ServiceDescriptor[] array, int arrayIndex) { }
public System.Collections.Generic.IEnumerator<Microsoft.Extensions.DependencyInjection.ServiceDescriptor> GetEnumerator() { throw null; }
public int IndexOf(Microsoft.Extensions.DependencyInjection.ServiceDescriptor item) { throw null; }
public void Insert(int index, Microsoft.Extensions.DependencyInjection.ServiceDescriptor item) { }
public bool Remove(Microsoft.Extensions.DependencyInjection.ServiceDescriptor item) { throw null; }
public void RemoveAt(int index) { }
void System.Collections.Generic.ICollection<Microsoft.Extensions.DependencyInjection.ServiceDescriptor>.Add(Microsoft.Extensions.DependencyInjection.ServiceDescriptor item) { }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
public static partial class ServiceCollectionContainerBuilderExtensions
{
public static Microsoft.Extensions.DependencyInjection.ServiceProvider BuildServiceProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { throw null; }
public static Microsoft.Extensions.DependencyInjection.ServiceProvider BuildServiceProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Microsoft.Extensions.DependencyInjection.ServiceProviderOptions options) { throw null; }
public static Microsoft.Extensions.DependencyInjection.ServiceProvider BuildServiceProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, bool validateScopes) { throw null; }
}
public sealed partial class ServiceProvider : System.IAsyncDisposable, System.IDisposable, System.IServiceProvider
{
internal ServiceProvider() { }
public void Dispose() { }
public System.Threading.Tasks.ValueTask DisposeAsync() { throw null; }
public object GetService(System.Type serviceType) { throw null; }
}
public partial class ServiceProviderOptions
{
public ServiceProviderOptions() { }
public bool ValidateOnBuild { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public bool ValidateScopes { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

<PropertyGroup>
<Description>Default implementation of dependency injection for Microsoft.Extensions.DependencyInjection.</Description>
<TargetFrameworks>netcoreapp3.0;net461;netstandard2.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0;net461;netstandard2.0;netstandard2.1</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>dependencyinjection;di</PackageTags>
<IsPackable>true</IsPackable>
<IsShipping>true</IsShipping>

<ILEmitBackend Condition="$(TargetFramework) != 'netstandard2.0'">True</ILEmitBackend>
<DefineConstants Condition="'$(ILEmitBackend)' == 'True'">$(DefineConstants);IL_EMIT</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)' == 'netcoreapp3.0'">$(DefineConstants);DISPOSE_ASYNC</DefineConstants>

<!-- Debug IL generation -->
<ILEmitBackendSaveAssemblies>False</ILEmitBackendSaveAssemblies>
Expand All @@ -26,6 +25,10 @@
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net461' Or '$(TargetFramework)' == 'netstandard2.0'">
<Reference Include="Microsoft.Bcl.AsyncInterfaces" />
</ItemGroup>

<ItemGroup>
<Compile Remove="ServiceLookup\ILEmit\**\*.cs" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

namespace Microsoft.Extensions.DependencyInjection.ServiceLookup
{
internal interface IServiceProviderEngine : IServiceProvider, IDisposable
#if DISPOSE_ASYNC
, IAsyncDisposable
#endif
internal interface IServiceProviderEngine : IServiceProvider, IDisposable, IAsyncDisposable
{
IServiceScope RootScope { get; }
void ValidateService(ServiceDescriptor descriptor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Reflection;

namespace Microsoft.Extensions.DependencyInjection.ServiceLookup
{
Expand All @@ -21,17 +20,9 @@ protected ServiceCallSite(ResultCache cache)
public abstract CallSiteKind Kind { get; }
public ResultCache Cache { get; }

public bool CaptureDisposable
{
get
{
return ImplementationType == null ||
typeof(IDisposable).GetTypeInfo().IsAssignableFrom(ImplementationType.GetTypeInfo())
#if DISPOSE_ASYNC
|| typeof(IAsyncDisposable).GetTypeInfo().IsAssignableFrom(ImplementationType.GetTypeInfo())
#endif
;
}
}
public bool CaptureDisposable =>
ImplementationType == null ||
typeof(IDisposable).IsAssignableFrom(ImplementationType) ||
typeof(IAsyncDisposable).IsAssignableFrom(ImplementationType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,11 @@ public void Dispose()
Root.Dispose();
}

#if DISPOSE_ASYNC
public ValueTask DisposeAsync()
{
_disposed = true;
return Root.DisposeAsync();
}
#endif

internal object GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@

namespace Microsoft.Extensions.DependencyInjection.ServiceLookup
{
internal class ServiceProviderEngineScope : IServiceScope, IServiceProvider
#if DISPOSE_ASYNC
, IAsyncDisposable
#endif
internal class ServiceProviderEngineScope : IServiceScope, IServiceProvider, IAsyncDisposable
{
// For testing only
internal Action<object> _captureDisposableCallback;
Expand Down Expand Up @@ -48,12 +45,7 @@ internal object CaptureDisposable(object service)

_captureDisposableCallback?.Invoke(service);

if (ReferenceEquals(this, service) ||
!(service is IDisposable
#if DISPOSE_ASYNC
|| service is IAsyncDisposable
#endif
))
if (ReferenceEquals(this, service) || !(service is IDisposable || service is IAsyncDisposable))
{
return service;
}
Expand Down Expand Up @@ -90,7 +82,6 @@ public void Dispose()
}
}

#if DISPOSE_ASYNC
public ValueTask DisposeAsync()
{
var toDispose = BeginDispose();
Expand Down Expand Up @@ -146,7 +137,6 @@ async ValueTask Await(int i, ValueTask vt)
}
}
}
#endif

private List<object> BeginDispose()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <summary>
/// The default IServiceProvider.
/// </summary>
public sealed class ServiceProvider : IServiceProvider, IDisposable, IServiceProviderEngineCallback
#if DISPOSE_ASYNC
, IAsyncDisposable
#endif
public sealed class ServiceProvider : IServiceProvider, IDisposable, IServiceProviderEngineCallback, IAsyncDisposable
{
private readonly IServiceProviderEngine _engine;

Expand Down Expand Up @@ -111,12 +108,10 @@ void IServiceProviderEngineCallback.OnResolve(Type serviceType, IServiceScope sc
_callSiteValidator.ValidateResolution(serviceType, scope, _engine.RootScope);
}

#if DISPOSE_ASYNC
/// <inheritdoc/>
public ValueTask DisposeAsync()
{
return _engine.DisposeAsync();
}
#endif
}
}

This file was deleted.

Loading

0 comments on commit e5d3ea0

Please sign in to comment.