Skip to content

Add LinkabilityChecker tool #40342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 22 additions & 32 deletions AspNetCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Compon
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Components.SdkAnalyzers.Tests", "src\Tools\SDK-Analyzers\Components\test\Microsoft.AspNetCore.Components.SdkAnalyzers.Tests.csproj", "{DC349A25-0DBF-4468-99E1-B95C22D3A7EF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LinkabilityChecker", "LinkabilityChecker", "{94F95276-7CDF-44A8-B159-D09702EF6794}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LinkabilityChecker", "src\Tools\LinkabilityChecker\LinkabilityChecker.csproj", "{EA7D844B-C180-41C7-9D55-273AD88BF71F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -3414,38 +3418,6 @@ Global
{8DE6625B-C9E4-4949-A75C-89E3FF556724}.Release|x64.Build.0 = Release|Any CPU
{8DE6625B-C9E4-4949-A75C-89E3FF556724}.Release|x86.ActiveCfg = Release|Any CPU
{8DE6625B-C9E4-4949-A75C-89E3FF556724}.Release|x86.Build.0 = Release|Any CPU
{BE5D6903-34B9-4C29-85A2-811A7EA06DAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BE5D6903-34B9-4C29-85A2-811A7EA06DAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BE5D6903-34B9-4C29-85A2-811A7EA06DAF}.Debug|arm64.ActiveCfg = Debug|Any CPU
{BE5D6903-34B9-4C29-85A2-811A7EA06DAF}.Debug|arm64.Build.0 = Debug|Any CPU
{BE5D6903-34B9-4C29-85A2-811A7EA06DAF}.Debug|x64.ActiveCfg = Debug|Any CPU
{BE5D6903-34B9-4C29-85A2-811A7EA06DAF}.Debug|x64.Build.0 = Debug|Any CPU
{BE5D6903-34B9-4C29-85A2-811A7EA06DAF}.Debug|x86.ActiveCfg = Debug|Any CPU
{BE5D6903-34B9-4C29-85A2-811A7EA06DAF}.Debug|x86.Build.0 = Debug|Any CPU
{BE5D6903-34B9-4C29-85A2-811A7EA06DAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BE5D6903-34B9-4C29-85A2-811A7EA06DAF}.Release|Any CPU.Build.0 = Release|Any CPU
{BE5D6903-34B9-4C29-85A2-811A7EA06DAF}.Release|arm64.ActiveCfg = Release|Any CPU
{BE5D6903-34B9-4C29-85A2-811A7EA06DAF}.Release|arm64.Build.0 = Release|Any CPU
{BE5D6903-34B9-4C29-85A2-811A7EA06DAF}.Release|x64.ActiveCfg = Release|Any CPU
{BE5D6903-34B9-4C29-85A2-811A7EA06DAF}.Release|x64.Build.0 = Release|Any CPU
{BE5D6903-34B9-4C29-85A2-811A7EA06DAF}.Release|x86.ActiveCfg = Release|Any CPU
{BE5D6903-34B9-4C29-85A2-811A7EA06DAF}.Release|x86.Build.0 = Release|Any CPU
{F3F89B56-66A9-4EBC-8658-80785827237E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F3F89B56-66A9-4EBC-8658-80785827237E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F3F89B56-66A9-4EBC-8658-80785827237E}.Debug|arm64.ActiveCfg = Debug|Any CPU
{F3F89B56-66A9-4EBC-8658-80785827237E}.Debug|arm64.Build.0 = Debug|Any CPU
{F3F89B56-66A9-4EBC-8658-80785827237E}.Debug|x64.ActiveCfg = Debug|Any CPU
{F3F89B56-66A9-4EBC-8658-80785827237E}.Debug|x64.Build.0 = Debug|Any CPU
{F3F89B56-66A9-4EBC-8658-80785827237E}.Debug|x86.ActiveCfg = Debug|Any CPU
{F3F89B56-66A9-4EBC-8658-80785827237E}.Debug|x86.Build.0 = Debug|Any CPU
{F3F89B56-66A9-4EBC-8658-80785827237E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F3F89B56-66A9-4EBC-8658-80785827237E}.Release|Any CPU.Build.0 = Release|Any CPU
{F3F89B56-66A9-4EBC-8658-80785827237E}.Release|arm64.ActiveCfg = Release|Any CPU
{F3F89B56-66A9-4EBC-8658-80785827237E}.Release|arm64.Build.0 = Release|Any CPU
{F3F89B56-66A9-4EBC-8658-80785827237E}.Release|x64.ActiveCfg = Release|Any CPU
{F3F89B56-66A9-4EBC-8658-80785827237E}.Release|x64.Build.0 = Release|Any CPU
{F3F89B56-66A9-4EBC-8658-80785827237E}.Release|x86.ActiveCfg = Release|Any CPU
{F3F89B56-66A9-4EBC-8658-80785827237E}.Release|x86.Build.0 = Release|Any CPU
{B81C7FA1-870F-4F21-A928-A5BE18754E6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B81C7FA1-870F-4F21-A928-A5BE18754E6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B81C7FA1-870F-4F21-A928-A5BE18754E6E}.Debug|arm64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -9966,6 +9938,22 @@ Global
{DC349A25-0DBF-4468-99E1-B95C22D3A7EF}.Release|x64.Build.0 = Release|Any CPU
{DC349A25-0DBF-4468-99E1-B95C22D3A7EF}.Release|x86.ActiveCfg = Release|Any CPU
{DC349A25-0DBF-4468-99E1-B95C22D3A7EF}.Release|x86.Build.0 = Release|Any CPU
{EA7D844B-C180-41C7-9D55-273AD88BF71F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EA7D844B-C180-41C7-9D55-273AD88BF71F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA7D844B-C180-41C7-9D55-273AD88BF71F}.Debug|arm64.ActiveCfg = Debug|Any CPU
{EA7D844B-C180-41C7-9D55-273AD88BF71F}.Debug|arm64.Build.0 = Debug|Any CPU
{EA7D844B-C180-41C7-9D55-273AD88BF71F}.Debug|x64.ActiveCfg = Debug|Any CPU
{EA7D844B-C180-41C7-9D55-273AD88BF71F}.Debug|x64.Build.0 = Debug|Any CPU
{EA7D844B-C180-41C7-9D55-273AD88BF71F}.Debug|x86.ActiveCfg = Debug|Any CPU
{EA7D844B-C180-41C7-9D55-273AD88BF71F}.Debug|x86.Build.0 = Debug|Any CPU
{EA7D844B-C180-41C7-9D55-273AD88BF71F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EA7D844B-C180-41C7-9D55-273AD88BF71F}.Release|Any CPU.Build.0 = Release|Any CPU
{EA7D844B-C180-41C7-9D55-273AD88BF71F}.Release|arm64.ActiveCfg = Release|Any CPU
{EA7D844B-C180-41C7-9D55-273AD88BF71F}.Release|arm64.Build.0 = Release|Any CPU
{EA7D844B-C180-41C7-9D55-273AD88BF71F}.Release|x64.ActiveCfg = Release|Any CPU
{EA7D844B-C180-41C7-9D55-273AD88BF71F}.Release|x64.Build.0 = Release|Any CPU
{EA7D844B-C180-41C7-9D55-273AD88BF71F}.Release|x86.ActiveCfg = Release|Any CPU
{EA7D844B-C180-41C7-9D55-273AD88BF71F}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -10786,6 +10774,8 @@ Global
{CC45FA2D-128B-485D-BA6D-DFD9735CB3C3} = {6C06163A-80E9-49C1-817C-B391852BA563}
{825BCF97-67A9-4834-B3A8-C3DC97A90E41} = {CC45FA2D-128B-485D-BA6D-DFD9735CB3C3}
{DC349A25-0DBF-4468-99E1-B95C22D3A7EF} = {CC45FA2D-128B-485D-BA6D-DFD9735CB3C3}
{94F95276-7CDF-44A8-B159-D09702EF6794} = {0B200A66-B809-4ED3-A790-CB1C2E80975E}
{EA7D844B-C180-41C7-9D55-273AD88BF71F} = {94F95276-7CDF-44A8-B159-D09702EF6794}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3E8720B3-DBDD-498C-B383-2CC32A054E8F}
Expand Down
2 changes: 2 additions & 0 deletions eng/Dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ and are generated based on the last package release.
<LatestPackageReference Include="System.Runtime.InteropServices.RuntimeInformation" />
<LatestPackageReference Include="System.Security.Cryptography.Pkcs" />
<LatestPackageReference Include="System.Security.Cryptography.Xml" />
<LatestPackageReference Include="System.Security.Permissions" />
<LatestPackageReference Include="System.Security.Principal.Windows" />
<LatestPackageReference Include="System.Text.Encodings.Web" />
<LatestPackageReference Include="System.Text.Json" />
<LatestPackageReference Include="System.Threading.AccessControl" />
<LatestPackageReference Include="System.Threading.Channels" />
<LatestPackageReference Include="System.Threading.RateLimiting" />
<LatestPackageReference Include="System.ValueTuple" />
Expand Down
8 changes: 8 additions & 0 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>e069de8777bc7c972b898a5c31d80ca9e23bbbef</Sha>
</Dependency>
<Dependency Name="System.Security.Permissions" Version="7.0.0-preview.3.22122.7">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>e069de8777bc7c972b898a5c31d80ca9e23bbbef</Sha>
</Dependency>
<Dependency Name="System.ServiceProcess.ServiceController" Version="7.0.0-preview.3.22122.7">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>e069de8777bc7c972b898a5c31d80ca9e23bbbef</Sha>
Expand All @@ -237,6 +241,10 @@
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>e069de8777bc7c972b898a5c31d80ca9e23bbbef</Sha>
</Dependency>
<Dependency Name="System.Threading.AccessControl" Version="7.0.0-preview.3.22122.7">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>e069de8777bc7c972b898a5c31d80ca9e23bbbef</Sha>
</Dependency>
<Dependency Name="System.Threading.Channels" Version="7.0.0-preview.3.22122.7">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>e069de8777bc7c972b898a5c31d80ca9e23bbbef</Sha>
Expand Down
2 changes: 2 additions & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,11 @@
<SystemRuntimeCompilerServicesUnsafeVersion>7.0.0-preview.3.22118.9</SystemRuntimeCompilerServicesUnsafeVersion>
<SystemSecurityCryptographyPkcsVersion>7.0.0-preview.3.22122.7</SystemSecurityCryptographyPkcsVersion>
<SystemSecurityCryptographyXmlVersion>7.0.0-preview.3.22122.7</SystemSecurityCryptographyXmlVersion>
<SystemSecurityPermissionsVersion>7.0.0-preview.3.22122.7</SystemSecurityPermissionsVersion>
<SystemServiceProcessServiceControllerVersion>7.0.0-preview.3.22122.7</SystemServiceProcessServiceControllerVersion>
<SystemTextEncodingsWebVersion>7.0.0-preview.3.22122.7</SystemTextEncodingsWebVersion>
<SystemTextJsonVersion>7.0.0-preview.3.22122.7</SystemTextJsonVersion>
<SystemThreadingAccessControlVersion>7.0.0-preview.3.22122.7</SystemThreadingAccessControlVersion>
<SystemThreadingChannelsVersion>7.0.0-preview.3.22122.7</SystemThreadingChannelsVersion>
<SystemThreadingRateLimitingVersion>7.0.0-preview.3.22122.7</SystemThreadingRateLimitingVersion>
<!-- Only listed explicitly to workaround https://github.com/dotnet/cli/issues/10528 -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>Provides abstractions for a loosly coupled collection of features.
Expand All @@ -12,7 +12,7 @@ Microsoft.AspNetCore.Http.Features.FeatureCollection
<IsAspNetCoreApp>true</IsAspNetCoreApp>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore</PackageTags>
<Nullable>enable</Nullable>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is nullable being removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nullable is now turned on by default for all projects. Removing because it's redundent.

<Trimmable>true</Trimmable>
</PropertyGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Http/Headers/src/Microsoft.Net.Http.Headers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>http</PackageTags>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Trimmable>true</Trimmable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ public static class UseMiddlewareExtensions
/// <param name="middleware">The middleware type.</param>
/// <param name="args">The arguments to pass to the middleware type instance's constructor.</param>
/// <returns>The <see cref="IApplicationBuilder"/> instance.</returns>
public static IApplicationBuilder UseMiddleware(this IApplicationBuilder app, [DynamicallyAccessedMembers(MiddlewareAccessibility)] Type middleware, params object?[] args)
public static IApplicationBuilder UseMiddleware(
this IApplicationBuilder app,
[DynamicallyAccessedMembers(MiddlewareAccessibility)] Type middleware,
params object?[] args)
{
if (typeof(IMiddleware).IsAssignableFrom(middleware))
{
Expand Down Expand Up @@ -112,7 +115,9 @@ public static IApplicationBuilder UseMiddleware(this IApplicationBuilder app, [D
});
}

private static IApplicationBuilder UseMiddlewareInterface(IApplicationBuilder app, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type middlewareType)
private static IApplicationBuilder UseMiddlewareInterface(
IApplicationBuilder app,
[DynamicallyAccessedMembers(MiddlewareAccessibility)] Type middlewareType)
{
return app.Use(next =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Microsoft.AspNetCore.Http.HttpResponse</Description>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore</PackageTags>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore</PackageTags>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<Trimmable>true</Trimmable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore</PackageTags>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<Trimmable>true</Trimmable>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/ObjectPool/src/Microsoft.Extensions.ObjectPool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>pooling</PackageTags>
<IsAspNetCoreApp>true</IsAspNetCoreApp>
<Nullable>enable</Nullable>
<Trimmable>true</Trimmable>
</PropertyGroup>

<ItemGroup>
Expand Down
30 changes: 22 additions & 8 deletions src/Shared/ActivatorUtilities/ActivatorUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#nullable disable warnings
#nullable enable annotations
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
Expand All @@ -29,6 +30,8 @@ namespace Microsoft.Extensions.Internal;
#endif
static class ActivatorUtilities
{
private const DynamicallyAccessedMemberTypes ActivatorAccessibility = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors;

private static readonly MethodInfo GetServiceInfo =
GetMethodInfo<Func<IServiceProvider, Type, Type, bool, object>>((sp, t, r, c) => GetService(sp, t, r, c));

Expand All @@ -39,7 +42,10 @@ static class ActivatorUtilities
/// <param name="instanceType">The type to activate</param>
/// <param name="parameters">Constructor arguments not provided by the <paramref name="provider"/>.</param>
/// <returns>An activated object of type instanceType</returns>
public static object CreateInstance(IServiceProvider provider, Type instanceType, params object[] parameters)
public static object CreateInstance(
IServiceProvider provider,
[DynamicallyAccessedMembers(ActivatorAccessibility)] Type instanceType,
params object[] parameters)
{
int bestLength = -1;
var seenPreferred = false;
Expand Down Expand Up @@ -98,7 +104,9 @@ public static object CreateInstance(IServiceProvider provider, Type instanceType
/// A factory that will instantiate instanceType using an <see cref="IServiceProvider"/>
/// and an argument array containing objects matching the types defined in argumentTypes
/// </returns>
public static ObjectFactory CreateFactory(Type instanceType, Type[] argumentTypes)
public static ObjectFactory CreateFactory(
[DynamicallyAccessedMembers(ActivatorAccessibility)] Type instanceType,
Type[] argumentTypes)
{
FindApplicableConstructor(instanceType, argumentTypes, out ConstructorInfo constructor, out int?[] parameterMap);

Expand All @@ -120,7 +128,9 @@ public static ObjectFactory CreateFactory(Type instanceType, Type[] argumentType
/// <param name="provider">The service provider used to resolve dependencies</param>
/// <param name="parameters">Constructor arguments not provided by the <paramref name="provider"/>.</param>
/// <returns>An activated object of type T</returns>
public static T CreateInstance<T>(IServiceProvider provider, params object[] parameters)
public static T CreateInstance<
[DynamicallyAccessedMembers(ActivatorAccessibility)] T
>(IServiceProvider provider, params object[] parameters)
{
return (T)CreateInstance(provider, typeof(T), parameters);
}
Expand All @@ -131,7 +141,9 @@ public static T CreateInstance<T>(IServiceProvider provider, params object[] par
/// <typeparam name="T">The type of the service</typeparam>
/// <param name="provider">The service provider used to resolve dependencies</param>
/// <returns>The resolved service or created instance</returns>
public static T GetServiceOrCreateInstance<T>(IServiceProvider provider)
public static T GetServiceOrCreateInstance<
[DynamicallyAccessedMembers(ActivatorAccessibility)] T
>(IServiceProvider provider)
{
return (T)GetServiceOrCreateInstance(provider, typeof(T));
}
Expand All @@ -142,7 +154,9 @@ public static T GetServiceOrCreateInstance<T>(IServiceProvider provider)
/// <param name="provider">The service provider</param>
/// <param name="type">The type of the service</param>
/// <returns>The resolved service or created instance</returns>
public static object GetServiceOrCreateInstance(IServiceProvider provider, Type type)
public static object GetServiceOrCreateInstance(
IServiceProvider provider,
[DynamicallyAccessedMembers(ActivatorAccessibility)] Type type)
{
return provider.GetService(type) ?? CreateInstance(provider, type);
}
Expand Down Expand Up @@ -207,7 +221,7 @@ private static Expression BuildFactoryExpression(
}

private static void FindApplicableConstructor(
Type instanceType,
[DynamicallyAccessedMembers(ActivatorAccessibility)] Type instanceType,
Type[] argumentTypes,
out ConstructorInfo matchingConstructor,
out int?[] parameterMap)
Expand All @@ -225,7 +239,7 @@ private static void FindApplicableConstructor(

// Tries to find constructor based on provided argument types
private static bool TryFindMatchingConstructor(
Type instanceType,
[DynamicallyAccessedMembers(ActivatorAccessibility)] Type instanceType,
Type[] argumentTypes,
ref ConstructorInfo matchingConstructor,
ref int?[] parameterMap)
Expand All @@ -249,7 +263,7 @@ private static bool TryFindMatchingConstructor(

// Tries to find constructor marked with ActivatorUtilitiesConstructorAttribute
private static bool TryFindPreferredConstructor(
Type instanceType,
[DynamicallyAccessedMembers(ActivatorAccessibility)] Type instanceType,
Type[] argumentTypes,
ref ConstructorInfo matchingConstructor,
ref int?[] parameterMap)
Expand Down
Loading