Skip to content

Commit

Permalink
fixed get service call generation (#1515)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-driscoll authored Apr 15, 2024
1 parent 76ecafb commit 726447e
Show file tree
Hide file tree
Showing 8 changed files with 433 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Conventions.Analyzers/Support/ExportConventions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ private static ExpressionSyntax NewConventionOrActivate(INamedTypeSymbol convent
InvocationExpression(
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName("builder"),
MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, IdentifierName("builder"), IdentifierName("Properties")),
GenericName(Identifier("GetService"))
.WithTypeArgumentList(
TypeArgumentList(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
//HintName: Rocket.Surgery.Conventions.Analyzers/Rocket.Surgery.Conventions.ConventionAttributesGenerator/Compiled_AssemblyProvider.cs
using System;
using System.Collections.Generic;
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
using Rocket.Surgery.Conventions;
using Rocket.Surgery.Conventions.Reflection;
using System.Runtime.Loader;

namespace TestProject.Conventions
{
internal sealed partial class Imports
{
#pragma warning disable CA1822
public IAssemblyProvider CreateAssemblyProvider(ConventionContextBuilder builder) => new AssemblyProvider(builder.Properties.GetRequiredService<AssemblyLoadContext>());
[System.CodeDom.Compiler.GeneratedCode("Rocket.Surgery.Conventions.Analyzers", "version"), System.Runtime.CompilerServices.CompilerGenerated, System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
private class AssemblyProvider(AssemblyLoadContext context) : IAssemblyProvider
{
IEnumerable<Assembly> IAssemblyProvider.GetAssemblies(Action<IAssemblyProviderAssemblySelector> action, string filePath, string memberName, int lineNumber)
{
yield break;
}

IEnumerable<Type> IAssemblyProvider.GetTypes(Func<ITypeProviderAssemblySelector, IEnumerable<Type>> selector, string filePath, string memberName, int lineNumber)
{
switch (lineNumber)
{
// FilePath: Input1.cs Member: Register
case 16:
yield return RocketSurgeryConventionsAbstractions.GetType("EnumPolyfill");
yield return typeof(global::Microsoft.Extensions.Configuration.RocketSurgeryLoggingExtensions);
yield return RocketSurgeryConventions.GetType("Microsoft.Extensions.DependencyInjection.LoggingBuilder");
yield return typeof(global::Microsoft.Extensions.DependencyInjection.RocketSurgeryServiceCollectionExtensions);
yield return typeof(global::Microsoft.Extensions.Logging.RocketSurgeryLoggingExtensions);
yield return RocketSurgeryConventionsAbstractions.GetType("Polyfill");
yield return RocketSurgeryConventionsAbstractions.GetType("RegexPolyfill");
yield return typeof(global::Rocket.Surgery.Conventions.AbstractConventionContextBuilderExtensions);
yield return RocketSurgeryConventionsAbstractions.GetType("Rocket.Surgery.Conventions.Abstractions.Conventions.Imports");
yield return RocketSurgeryConventionsAbstractions.GetType("Rocket.Surgery.Conventions.Abstractions.Conventions.Imports+AssemblyProvider");
yield return RocketSurgeryConventionsAbstractions.GetType("Rocket.Surgery.Conventions.Adapters.IServiceFactoryAdapter");
yield return RocketSurgeryConventionsAbstractions.GetType("Rocket.Surgery.Conventions.Adapters.ServiceFactoryAdapter`1");
yield return typeof(global::Rocket.Surgery.Conventions.AfterConventionAttribute);
yield return typeof(global::Rocket.Surgery.Conventions.AfterConventionAttribute<>);
yield return RocketSurgeryConventionsAbstractions.GetType("Rocket.Surgery.Conventions.AssemblyProviderFactory");
yield return typeof(global::Rocket.Surgery.Conventions.BeforeConventionAttribute);
yield return typeof(global::Rocket.Surgery.Conventions.BeforeConventionAttribute<>);
yield return typeof(global::Rocket.Surgery.Conventions.Configuration.ConfigurationAsyncConvention);
yield return typeof(global::Rocket.Surgery.Conventions.Configuration.ConfigurationBuilderApplicationDelegate);
yield return typeof(global::Rocket.Surgery.Conventions.Configuration.ConfigurationBuilderDelegateResult);
yield return typeof(global::Rocket.Surgery.Conventions.Configuration.ConfigurationBuilderEnvironmentDelegate);
yield return typeof(global::Rocket.Surgery.Conventions.Configuration.ConfigurationConvention);
yield return typeof(global::Rocket.Surgery.Conventions.Configuration.ConfigurationOptionsExtensions);
yield return typeof(global::Rocket.Surgery.Conventions.Configuration.IConfigurationAsyncConvention);
yield return typeof(global::Rocket.Surgery.Conventions.Configuration.IConfigurationConvention);
yield return typeof(global::Rocket.Surgery.Conventions.ConventionAttribute);
yield return typeof(global::Rocket.Surgery.Conventions.ConventionAttribute<>);
yield return typeof(global::Rocket.Surgery.Conventions.ConventionContext);
yield return typeof(global::Rocket.Surgery.Conventions.ConventionContextBuilder);
yield return typeof(global::Rocket.Surgery.Conventions.ConventionContextBuilderExtensions);
yield return typeof(global::Rocket.Surgery.Conventions.ConventionContextExtensions);
yield return RocketSurgeryConventions.GetType("Rocket.Surgery.Conventions.ConventionContextHelpers");
yield return RocketSurgeryConventionsAbstractions.GetType("Rocket.Surgery.Conventions.ConventionDependency");
yield return typeof(global::Rocket.Surgery.Conventions.ConventionHostBuilderExtensions);
yield return RocketSurgeryConventionsAbstractions.GetType("Rocket.Surgery.Conventions.ConventionHostBuilderExtensions+ServiceProviderWrapper`1");
yield return RocketSurgeryConventionsAbstractions.GetType("Rocket.Surgery.Conventions.ConventionOrDelegate");
yield return RocketSurgeryConventionsAbstractions.GetType("Rocket.Surgery.Conventions.ConventionProvider");
yield return typeof(global::Rocket.Surgery.Conventions.ConventionsConfigurationAttribute);
yield return typeof(global::Rocket.Surgery.Conventions.ConventionWithDependencies);
yield return typeof(global::Rocket.Surgery.Conventions.DependencyDirection);
yield return typeof(global::Rocket.Surgery.Conventions.DependencyInjection.IServiceAsyncConvention);
yield return typeof(global::Rocket.Surgery.Conventions.DependencyInjection.IServiceConvention);
yield return typeof(global::Rocket.Surgery.Conventions.DependencyInjection.ServiceAsyncConvention);
yield return typeof(global::Rocket.Surgery.Conventions.DependencyInjection.ServiceConvention);
yield return typeof(global::Rocket.Surgery.Conventions.DependentOfConventionAttribute);
yield return typeof(global::Rocket.Surgery.Conventions.DependentOfConventionAttribute<>);
yield return typeof(global::Rocket.Surgery.Conventions.DependsOnConventionAttribute);
yield return typeof(global::Rocket.Surgery.Conventions.DependsOnConventionAttribute<>);
yield return typeof(global::Rocket.Surgery.Conventions.ExportConventionAttribute);
yield return typeof(global::Rocket.Surgery.Conventions.ExportConventionsAttribute);
yield return typeof(global::Rocket.Surgery.Conventions.ExportedConventionsAttribute);
yield return RocketSurgeryConventions.GetType("Rocket.Surgery.Conventions.Extensions.RocketSurgerySetupExtensions");
yield return typeof(global::Rocket.Surgery.Conventions.HostType);
yield return typeof(global::Rocket.Surgery.Conventions.IAssemblyProvider);
yield return typeof(global::Rocket.Surgery.Conventions.IConvention);
yield return typeof(global::Rocket.Surgery.Conventions.IConventionContext);
yield return typeof(global::Rocket.Surgery.Conventions.IConventionDependency);
yield return typeof(global::Rocket.Surgery.Conventions.IConventionFactory);
yield return typeof(global::Rocket.Surgery.Conventions.IConventionProvider);
yield return typeof(global::Rocket.Surgery.Conventions.IConventionWithDependencies);
yield return RocketSurgeryConventionsAbstractions.GetType("Rocket.Surgery.Conventions.IHostBasedConvention");
yield return typeof(global::Rocket.Surgery.Conventions.ImportConventionsAttribute);
yield return RocketSurgeryConventions.GetType("Rocket.Surgery.Conventions.Imports");
yield return RocketSurgeryConventions.GetType("Rocket.Surgery.Conventions.Imports+AssemblyProvider");
yield return typeof(global::Rocket.Surgery.Conventions.IReadOnlyServiceProviderDictionary);
yield return typeof(global::Rocket.Surgery.Conventions.IServiceProviderDictionary);
yield return typeof(global::Rocket.Surgery.Conventions.LiveConventionAttribute);
yield return typeof(global::Rocket.Surgery.Conventions.Logging.ILoggingAsyncConvention);
yield return typeof(global::Rocket.Surgery.Conventions.Logging.ILoggingConvention);
yield return typeof(global::Rocket.Surgery.Conventions.Logging.LoggingAsyncConvention);
yield return typeof(global::Rocket.Surgery.Conventions.Logging.LoggingConvention);
yield return typeof(global::Rocket.Surgery.Conventions.Logging.RocketLoggingOptions);
yield return RocketSurgeryConventions.GetType("Rocket.Surgery.Conventions.LoggingExtensions");
yield return typeof(global::Rocket.Surgery.Conventions.ReadOnlyServiceProviderDictionary);
yield return RocketSurgeryConventions.GetType("Rocket.Surgery.Conventions.Reflection.AppDomainAssemblyProvider");
yield return typeof(global::Rocket.Surgery.Conventions.Reflection.AppDomainConventionFactory);
yield return RocketSurgeryConventions.GetType("Rocket.Surgery.Conventions.Reflection.AssemblyCandidateResolver");
yield return RocketSurgeryConventions.GetType("Rocket.Surgery.Conventions.Reflection.AssemblyCandidateResolver+Dependency");
yield return typeof(global::Rocket.Surgery.Conventions.Reflection.AssemblyConventionFactory);
yield return RocketSurgeryConventions.GetType("Rocket.Surgery.Conventions.Reflection.AssemblyProviderAssemblySelector");
yield return typeof(global::Rocket.Surgery.Conventions.Reflection.ConventionFactoryBase);
yield return RocketSurgeryConventions.GetType("Rocket.Surgery.Conventions.Reflection.DefaultAssemblyProvider");
yield return RocketSurgeryConventions.GetType("Rocket.Surgery.Conventions.Reflection.DependencyClassification");
yield return typeof(global::Rocket.Surgery.Conventions.Reflection.IAssemblyProviderAssemblySelector);
yield return typeof(global::Rocket.Surgery.Conventions.Reflection.ITypeFilter);
yield return typeof(global::Rocket.Surgery.Conventions.Reflection.ITypeProviderAssemblySelector);
yield return typeof(global::Rocket.Surgery.Conventions.Reflection.ITypeSelector);
yield return RocketSurgeryConventions.GetType("Rocket.Surgery.Conventions.Reflection.TypeFilter");
yield return typeof(global::Rocket.Surgery.Conventions.Reflection.TypeInfoFilter);
yield return typeof(global::Rocket.Surgery.Conventions.Reflection.TypeKindFilter);
yield return RocketSurgeryConventions.GetType("Rocket.Surgery.Conventions.Reflection.TypeProviderAssemblySelector");
yield return typeof(global::Rocket.Surgery.Conventions.ServiceProviderDictionary);
yield return typeof(global::Rocket.Surgery.Conventions.ServiceProviderDictionaryExtensions);
yield return RocketSurgeryConventionsAbstractions.GetType("Rocket.Surgery.Conventions.ServiceProviderFactoryAdapter");
yield return typeof(global::Rocket.Surgery.Conventions.Setup.ISetupAsyncConvention);
yield return typeof(global::Rocket.Surgery.Conventions.Setup.ISetupConvention);
yield return typeof(global::Rocket.Surgery.Conventions.Setup.SetupAsyncConvention);
yield return typeof(global::Rocket.Surgery.Conventions.Setup.SetupConvention);
yield return typeof(global::Rocket.Surgery.Conventions.Testing.TestConventionContextBuilderExtensions);
yield return RocketSurgeryConventionsAbstractions.GetType("Rocket.Surgery.Conventions.ThrowHelper");
yield return typeof(global::Rocket.Surgery.Conventions.UnitTestConventionAttribute);
yield return RocketSurgeryConventionsAbstractions.GetType("StringPolyfill");
yield return RocketSurgeryConventions.GetType("System.Runtime.CompilerServices.IsExternalInit");
break;
}
}

private Assembly _RocketSurgeryConventions;
private Assembly RocketSurgeryConventions => _RocketSurgeryConventions ??= context.LoadFromAssemblyName(new AssemblyName("Rocket.Surgery.Conventions, Version=version, Culture=neutral, PublicKeyToken=null"));

private Assembly _RocketSurgeryConventionsAbstractions;
private Assembly RocketSurgeryConventionsAbstractions => _RocketSurgeryConventionsAbstractions ??= context.LoadFromAssemblyName(new AssemblyName("Rocket.Surgery.Conventions.Abstractions, Version=version, Culture=neutral, PublicKeyToken=null"));
}
}
}
Loading

0 comments on commit 726447e

Please sign in to comment.