Skip to content

Commit d79344f

Browse files
committed
Remove reference projecs from nearly all OOBs
Contributes to #58163 This is a POC that demonstrates that most out-of-band reference projects in dotnet/runtime can be deleted. See reasoning in the linked issue. The remaining OOBs are more challenging as they are depend on the PNSE or PartialFacade infrastructure which itself depends on the reference source / reference assembly: System.Management (PNSE) System.Net.Http.WinHttpHandler (PNSE) System.Reflection.Context (PNSE) System.Security.Cryptography.Pkcs (Facade) System.Security.Cryptography.ProtectedData (Facade + PNSE) System.Security.Cryptography.Xml (Facade) System.Security.Permissions (Facade) System.ServiceModel.Syndication (Facade) System.ServiceProcess.ServiceController (Facade + PNSE) System.Speech (PNSE) System.Threading.AccessControl (Facade + PNSE) System.Windows.Extensions (PNSE)
1 parent 2330b4b commit d79344f

File tree

103 files changed

+667
-1490
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+667
-1490
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// ------------------------------------------------------------------------------
44
// Changes to this file must follow the https://aka.ms/api-review process.
5+
// This file is auto-generated and any changes to it will be lost.
56
// ------------------------------------------------------------------------------
67

7-
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(Microsoft.Extensions.DependencyInjection.ServiceCollection))]

eng/resolveContract.targets

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
<ContractDependencyPaths Condition="'$(ContractDependencyPaths)' == ''">@(ReferencePath->'%(RelativeDir)'->Distinct())</ContractDependencyPaths>
66
<!-- Fall back to the targeting pack dir for NetCoreAppCurrent to avoid passing through dependencies from ref to src. -->
77
<ContractDependencyPaths Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', '$(NetCoreAppCurrent)'))">$(ContractDependencyPaths);$(MicrosoftNetCoreAppRefPackRefDir)</ContractDependencyPaths>
8+
9+
<!-- Ignore the .ref.cs file-->
10+
<ReferenceSourceTargetName>$(TargetName).ref.g.cs</ReferenceSourceTargetName>
11+
<!-- Rename to DefaultExcludesInProjectFolder when https://github.com/dotnet/sdk/pull/24063 is merged and consumed. -->
12+
<DefaultItemExcludesInProjectFolder>$(ReferenceSourceTargetName)</DefaultItemExcludesInProjectFolder>
813
</PropertyGroup>
914

1015
<PropertyGroup>
@@ -14,6 +19,21 @@
1419
<GenAPILangVersion Condition="'$(LangVersion)' != ''">$(LangVersion)</GenAPILangVersion>
1520
</PropertyGroup>
1621

22+
<!-- Create a reference source file from the platform agnostic NetCoreAppCurrent assembly and make sure that it isn't treated as a compile input. -->
23+
<PropertyGroup Condition="'$(ProduceReferenceAssembly)' == 'true' and
24+
'$(IsSourceProject)' == 'true' and
25+
'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and
26+
$([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '$(NETCoreAppCurrentVersion)')) and
27+
'$(TargetFrameworkSuffix)' == '' and
28+
'$(DotNetBuildFromSource)' != 'true'">
29+
<!-- Use a different header and don't feed in an attribute exclusion list. -->
30+
<GenAPITargetPath>$(MSBuildProjectDirectory)\$(ReferenceSourceTargetName)</GenAPITargetPath>
31+
<GenAPIHeaderFile>$(RepositoryEngineeringDir)LicenseHeader.Generated.txt</GenAPIHeaderFile>
32+
<GenAPIExcludeAttributesList />
33+
<GenerateReferenceAssemblySource Condition="'$(GenerateReferenceAssemblySource)' == ''">true</GenerateReferenceAssemblySource>
34+
<TargetsTriggeredByCompilation>$(TargetsTriggeredByCompilation);GenerateReferenceAssemblySource</TargetsTriggeredByCompilation>
35+
</PropertyGroup>
36+
1737
<PropertyGroup Condition="'$(IsSourceProject)' == 'true'">
1838
<ContractProject Condition="'$(ContractProject)' == ''">$(LibrariesProjectRoot)$(MSBuildProjectName)\ref\$(MSBuildProjectName).csproj</ContractProject>
1939
<HasMatchingContract Condition="'$(HasMatchingContract)' == '' and Exists('$(ContractProject)')">true</HasMatchingContract>

src/libraries/Directory.Build.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@
7575
<PropertyGroup>
7676
<!-- Default any assembly not specifying a key to use the Open Key -->
7777
<StrongNameKeyId>Open</StrongNameKeyId>
78-
<!-- Microsoft.Extensions projects have a separate StrongNameKeyId -->
78+
<!-- Microsoft.Extensions projects have a separate StrongNameKeyId and no dedicated reference project. -->
7979
<StrongNameKeyId Condition="$(MSBuildProjectName.StartsWith('Microsoft.Extensions.'))">MicrosoftAspNetCore</StrongNameKeyId>
80+
<ProduceReferenceAssembly Condition="$(MSBuildProjectName.StartsWith('Microsoft.Extensions.')) and '$(IsSourceProject)' == 'true'">true</ProduceReferenceAssembly>
8081
<!-- We can't generate an apphost without restoring the targeting pack. -->
8182
<UseAppHost>false</UseAppHost>
8283
<EnableDefaultItems>false</EnableDefaultItems>

src/libraries/Microsoft.Extensions.Caching.Abstractions/ref/Microsoft.Extensions.Caching.Abstractions.csproj

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// ------------------------------------------------------------------------------
44
// Changes to this file must follow the https://aka.ms/api-review process.
5+
// This file is auto-generated and any changes to it will be lost.
56
// ------------------------------------------------------------------------------
67

78
namespace Microsoft.Extensions.Caching.Distributed
@@ -22,6 +23,7 @@ public DistributedCacheEntryOptions() { }
2223
public static partial class DistributedCacheExtensions
2324
{
2425
public static string? GetString(this Microsoft.Extensions.Caching.Distributed.IDistributedCache cache, string key) { throw null; }
26+
[System.Diagnostics.DebuggerStepThroughAttribute]
2527
public static System.Threading.Tasks.Task<string?> GetStringAsync(this Microsoft.Extensions.Caching.Distributed.IDistributedCache cache, string key, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) { throw null; }
2628
public static void Set(this Microsoft.Extensions.Caching.Distributed.IDistributedCache cache, string key, byte[] value) { }
2729
public static System.Threading.Tasks.Task SetAsync(this Microsoft.Extensions.Caching.Distributed.IDistributedCache cache, string key, byte[] value, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) { throw null; }
@@ -60,6 +62,7 @@ public static partial class CacheEntryExtensions
6062
public static partial class CacheExtensions
6163
{
6264
public static object? Get(this Microsoft.Extensions.Caching.Memory.IMemoryCache cache, object key) { throw null; }
65+
[System.Diagnostics.DebuggerStepThroughAttribute]
6366
public static System.Threading.Tasks.Task<TItem?> GetOrCreateAsync<TItem>(this Microsoft.Extensions.Caching.Memory.IMemoryCache cache, object key, System.Func<Microsoft.Extensions.Caching.Memory.ICacheEntry, System.Threading.Tasks.Task<TItem>> factory) { throw null; }
6467
public static TItem? GetOrCreate<TItem>(this Microsoft.Extensions.Caching.Memory.IMemoryCache cache, object key, System.Func<Microsoft.Extensions.Caching.Memory.ICacheEntry, TItem> factory) { throw null; }
6568
public static TItem? Get<TItem>(this Microsoft.Extensions.Caching.Memory.IMemoryCache cache, object key) { throw null; }
@@ -120,17 +123,17 @@ public partial class MemoryCacheEntryOptions
120123
public MemoryCacheEntryOptions() { }
121124
public System.DateTimeOffset? AbsoluteExpiration { get { throw null; } set { } }
122125
public System.TimeSpan? AbsoluteExpirationRelativeToNow { get { throw null; } set { } }
123-
public System.Collections.Generic.IList<Microsoft.Extensions.Primitives.IChangeToken> ExpirationTokens { get { throw null; } }
124-
public System.Collections.Generic.IList<Microsoft.Extensions.Caching.Memory.PostEvictionCallbackRegistration> PostEvictionCallbacks { get { throw null; } }
125-
public Microsoft.Extensions.Caching.Memory.CacheItemPriority Priority { get { throw null; } set { } }
126+
public System.Collections.Generic.IList<Microsoft.Extensions.Primitives.IChangeToken> ExpirationTokens { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
127+
public System.Collections.Generic.IList<Microsoft.Extensions.Caching.Memory.PostEvictionCallbackRegistration> PostEvictionCallbacks { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
128+
public Microsoft.Extensions.Caching.Memory.CacheItemPriority Priority { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
126129
public long? Size { get { throw null; } set { } }
127130
public System.TimeSpan? SlidingExpiration { get { throw null; } set { } }
128131
}
129132
public partial class PostEvictionCallbackRegistration
130133
{
131134
public PostEvictionCallbackRegistration() { }
132-
public Microsoft.Extensions.Caching.Memory.PostEvictionDelegate? EvictionCallback { get { throw null; } set { } }
133-
public object? State { get { throw null; } set { } }
135+
public Microsoft.Extensions.Caching.Memory.PostEvictionDelegate? EvictionCallback { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
136+
public object? State { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
134137
}
135138
public delegate void PostEvictionDelegate(object key, object? value, Microsoft.Extensions.Caching.Memory.EvictionReason reason, object? state);
136139
}

src/libraries/Microsoft.Extensions.Caching.Memory/ref/Microsoft.Extensions.Caching.Memory.csproj

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/libraries/Microsoft.Extensions.Caching.Memory/ref/Microsoft.Extensions.Caching.Memory.cs renamed to src/libraries/Microsoft.Extensions.Caching.Memory/src/Microsoft.Extensions.Caching.Memory.ref.g.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// ------------------------------------------------------------------------------
44
// Changes to this file must follow the https://aka.ms/api-review process.
5+
// This file is auto-generated and any changes to it will be lost.
56
// ------------------------------------------------------------------------------
67

78
namespace Microsoft.Extensions.Caching.Distributed
@@ -27,24 +28,24 @@ public partial class MemoryCache : Microsoft.Extensions.Caching.Memory.IMemoryCa
2728
public MemoryCache(Microsoft.Extensions.Options.IOptions<Microsoft.Extensions.Caching.Memory.MemoryCacheOptions> optionsAccessor) { }
2829
public MemoryCache(Microsoft.Extensions.Options.IOptions<Microsoft.Extensions.Caching.Memory.MemoryCacheOptions> optionsAccessor, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory) { }
2930
public int Count { get { throw null; } }
31+
public void Clear() { }
3032
public void Compact(double percentage) { }
3133
public Microsoft.Extensions.Caching.Memory.ICacheEntry CreateEntry(object key) { throw null; }
3234
public void Dispose() { }
3335
protected virtual void Dispose(bool disposing) { }
3436
~MemoryCache() { }
3537
public void Remove(object key) { }
3638
public bool TryGetValue(object key, out object? result) { throw null; }
37-
public void Clear() { }
3839
}
3940
public partial class MemoryCacheOptions : Microsoft.Extensions.Options.IOptions<Microsoft.Extensions.Caching.Memory.MemoryCacheOptions>
4041
{
4142
public MemoryCacheOptions() { }
42-
public Microsoft.Extensions.Internal.ISystemClock? Clock { get { throw null; } set { } }
43+
public Microsoft.Extensions.Internal.ISystemClock? Clock { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
4344
public double CompactionPercentage { get { throw null; } set { } }
44-
public System.TimeSpan ExpirationScanFrequency { get { throw null; } set { } }
45+
public System.TimeSpan ExpirationScanFrequency { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
4546
Microsoft.Extensions.Caching.Memory.MemoryCacheOptions Microsoft.Extensions.Options.IOptions<Microsoft.Extensions.Caching.Memory.MemoryCacheOptions>.Value { get { throw null; } }
4647
public long? SizeLimit { get { throw null; } set { } }
47-
public bool TrackLinkedCacheEntries { get { throw null; } set { } }
48+
public bool TrackLinkedCacheEntries { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
4849
}
4950
public partial class MemoryDistributedCacheOptions : Microsoft.Extensions.Caching.Memory.MemoryCacheOptions
5051
{

src/libraries/Microsoft.Extensions.Configuration.Abstractions/ref/Microsoft.Extensions.Configuration.Abstractions.csproj

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,50 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// ------------------------------------------------------------------------------
44
// Changes to this file must follow the https://aka.ms/api-review process.
5+
// This file is auto-generated and any changes to it will be lost.
56
// ------------------------------------------------------------------------------
67

78
namespace Microsoft.Extensions.Configuration
89
{
10+
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
11+
public readonly partial struct ConfigurationDebugViewContext
12+
{
13+
private readonly object _dummy;
14+
private readonly int _dummyPrimitive;
15+
public ConfigurationDebugViewContext(string path, string key, string? value, Microsoft.Extensions.Configuration.IConfigurationProvider configurationProvider) { throw null; }
16+
public Microsoft.Extensions.Configuration.IConfigurationProvider ConfigurationProvider { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
17+
public string Key { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
18+
public string Path { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
19+
public string? Value { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
20+
}
921
public static partial class ConfigurationExtensions
1022
{
1123
public static Microsoft.Extensions.Configuration.IConfigurationBuilder Add<TSource>(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, System.Action<TSource>? configureSource) where TSource : Microsoft.Extensions.Configuration.IConfigurationSource, new() { throw null; }
1224
public static System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, string?>> AsEnumerable(this Microsoft.Extensions.Configuration.IConfiguration configuration) { throw null; }
1325
public static System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, string?>> AsEnumerable(this Microsoft.Extensions.Configuration.IConfiguration configuration, bool makePathsRelative) { throw null; }
14-
public static bool Exists([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] this Microsoft.Extensions.Configuration.IConfigurationSection? section) { throw null; }
26+
public static bool Exists([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] this Microsoft.Extensions.Configuration.IConfigurationSection? section) { throw null; }
1527
public static string? GetConnectionString(this Microsoft.Extensions.Configuration.IConfiguration configuration, string name) { throw null; }
1628
public static Microsoft.Extensions.Configuration.IConfigurationSection GetRequiredSection(this Microsoft.Extensions.Configuration.IConfiguration configuration, string key) { throw null; }
1729
}
1830
[System.AttributeUsageAttribute(System.AttributeTargets.Property)]
1931
public sealed partial class ConfigurationKeyNameAttribute : System.Attribute
2032
{
2133
public ConfigurationKeyNameAttribute(string name) { }
22-
public string Name { get { throw null; } }
34+
public string Name { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
2335
}
2436
public static partial class ConfigurationPath
2537
{
2638
public static readonly string KeyDelimiter;
2739
public static string Combine(System.Collections.Generic.IEnumerable<string> pathSegments) { throw null; }
2840
public static string Combine(params string[] pathSegments) { throw null; }
2941
public static string? GetParentPath(string? path) { throw null; }
30-
[return: System.Diagnostics.CodeAnalysis.NotNullIfNotNull("path")]
42+
[return: System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute("path")]
3143
public static string? GetSectionKey(string? path) { throw null; }
3244
}
3345
public static partial class ConfigurationRootExtensions
3446
{
3547
public static string GetDebugView(this Microsoft.Extensions.Configuration.IConfigurationRoot root) { throw null; }
36-
public static string GetDebugView(this IConfigurationRoot root, System.Func<ConfigurationDebugViewContext, string>? processValue) { throw null; }
37-
}
38-
public readonly partial struct ConfigurationDebugViewContext
39-
{
40-
public ConfigurationDebugViewContext(string path, string key, string? value, IConfigurationProvider configurationProvider) { throw null; }
41-
public string Path { get; }
42-
public string Key { get; }
43-
public string? Value { get; }
44-
public IConfigurationProvider ConfigurationProvider { get; }
48+
public static string GetDebugView(this Microsoft.Extensions.Configuration.IConfigurationRoot root, System.Func<Microsoft.Extensions.Configuration.ConfigurationDebugViewContext, string>? processValue) { throw null; }
4549
}
4650
public partial interface IConfiguration
4751
{

0 commit comments

Comments
 (0)