|
| 1 | +using Basic.Reference.Assemblies; |
| 2 | +using GreenDonut; |
| 3 | +using GreenDonut.Data; |
| 4 | +using HotChocolate.Data.Filters; |
| 5 | +using HotChocolate.Execution; |
| 6 | +using HotChocolate.Execution.Configuration; |
| 7 | +using HotChocolate.Execution.Processing; |
| 8 | +using HotChocolate.Features; |
| 9 | +using HotChocolate.Language; |
| 10 | +using HotChocolate.Language.Visitors; |
| 11 | +using HotChocolate.Types.Pagination; |
| 12 | +using Microsoft.AspNetCore.Builder; |
| 13 | +using Microsoft.CodeAnalysis; |
| 14 | +using Microsoft.Extensions.DependencyInjection; |
| 15 | + |
| 16 | +namespace HotChocolate.Types; |
| 17 | + |
| 18 | +/// <summary> |
| 19 | +/// Provides the metadata references that mirror the HotChocolate package graph an |
| 20 | +/// application using the source generator would compile against. The list is shared by |
| 21 | +/// every in-memory compilation in this test project so that the generated registration |
| 22 | +/// code, the HotChocolate runtime, and the test process all bind to the same loaded |
| 23 | +/// assemblies (a requirement for type identity to hold across assembly load contexts). |
| 24 | +/// </summary> |
| 25 | +internal static class GeneratorReferences |
| 26 | +{ |
| 27 | + /// <summary> |
| 28 | + /// Gets the metadata references for an in-memory HotChocolate compilation. The list |
| 29 | + /// combines the framework reference assemblies for the active target framework with |
| 30 | + /// metadata references to the loaded HotChocolate assemblies. |
| 31 | + /// </summary> |
| 32 | + public static IReadOnlyList<PortableExecutableReference> All { get; } = |
| 33 | + [ |
| 34 | +#if NET8_0 |
| 35 | + .. Net80.References.All, |
| 36 | +#elif NET9_0 |
| 37 | + .. Net90.References.All, |
| 38 | +#elif NET10_0 |
| 39 | + .. Net100.References.All, |
| 40 | +#endif |
| 41 | + // HotChocolate.Primitives |
| 42 | + MetadataReference.CreateFromFile(typeof(ITypeSystemMember).Assembly.Location), |
| 43 | + |
| 44 | + // HotChocolate.Execution |
| 45 | + MetadataReference.CreateFromFile(typeof(RequestDelegate).Assembly.Location), |
| 46 | + |
| 47 | + // HotChocolate.Execution.Abstractions |
| 48 | + MetadataReference.CreateFromFile(typeof(RequestContext).Assembly.Location), |
| 49 | + |
| 50 | + // HotChocolate.Execution.Processing |
| 51 | + MetadataReference.CreateFromFile(typeof(HotChocolateExecutionSelectionExtensions).Assembly.Location), |
| 52 | + |
| 53 | + // HotChocolate.Execution.Abstractions |
| 54 | + MetadataReference.CreateFromFile(typeof(IRequestExecutorBuilder).Assembly.Location), |
| 55 | + |
| 56 | + // HotChocolate.Execution.Operation.Abstractions |
| 57 | + MetadataReference.CreateFromFile(typeof(ISelection).Assembly.Location), |
| 58 | + |
| 59 | + // HotChocolate.Types |
| 60 | + MetadataReference.CreateFromFile(typeof(ObjectTypeAttribute).Assembly.Location), |
| 61 | + MetadataReference.CreateFromFile(typeof(QueryTypeAttribute).Assembly.Location), |
| 62 | + MetadataReference.CreateFromFile(typeof(Connection).Assembly.Location), |
| 63 | + MetadataReference.CreateFromFile(typeof(PageConnection<>).Assembly.Location), |
| 64 | + |
| 65 | + // HotChocolate.Types.Abstractions |
| 66 | + MetadataReference.CreateFromFile(typeof(ISchemaDefinition).Assembly.Location), |
| 67 | + |
| 68 | + // HotChocolate.Features |
| 69 | + MetadataReference.CreateFromFile(typeof(IFeatureProvider).Assembly.Location), |
| 70 | + |
| 71 | + // HotChocolate.Language |
| 72 | + MetadataReference.CreateFromFile(typeof(OperationType).Assembly.Location), |
| 73 | + |
| 74 | + // HotChocolate.Language.Utf8 |
| 75 | + MetadataReference.CreateFromFile(typeof(ParserOptions).Assembly.Location), |
| 76 | + |
| 77 | + // HotChocolate.Language.Visitors |
| 78 | + MetadataReference.CreateFromFile(typeof(SyntaxVisitor).Assembly.Location), |
| 79 | + |
| 80 | + // HotChocolate.Abstractions |
| 81 | + MetadataReference.CreateFromFile(typeof(ParentAttribute).Assembly.Location), |
| 82 | + |
| 83 | + // HotChocolate.AspNetCore |
| 84 | + MetadataReference.CreateFromFile( |
| 85 | + typeof(HotChocolateAspNetCoreServiceCollectionExtensions).Assembly.Location), |
| 86 | + |
| 87 | + // GreenDonut |
| 88 | + MetadataReference.CreateFromFile(typeof(DataLoaderBase<,>).Assembly.Location), |
| 89 | + MetadataReference.CreateFromFile(typeof(IDataLoader).Assembly.Location), |
| 90 | + |
| 91 | + // GreenDonut.Data |
| 92 | + MetadataReference.CreateFromFile(typeof(PagingArguments).Assembly.Location), |
| 93 | + MetadataReference.CreateFromFile(typeof(IPredicateBuilder).Assembly.Location), |
| 94 | + MetadataReference.CreateFromFile(typeof(DefaultPredicateBuilder).Assembly.Location), |
| 95 | + |
| 96 | + // HotChocolate.Data |
| 97 | + MetadataReference.CreateFromFile(typeof(IFilterContext).Assembly.Location), |
| 98 | + |
| 99 | + // Microsoft.AspNetCore |
| 100 | + MetadataReference.CreateFromFile(typeof(WebApplication).Assembly.Location), |
| 101 | + |
| 102 | + // Microsoft.Extensions.DependencyInjection.Abstractions |
| 103 | + MetadataReference.CreateFromFile(typeof(IServiceCollection).Assembly.Location), |
| 104 | + |
| 105 | + // Microsoft.AspNetCore.Authorization |
| 106 | + MetadataReference.CreateFromFile(typeof(Microsoft.AspNetCore.Authorization.AuthorizeAttribute).Assembly.Location), |
| 107 | + |
| 108 | + // HotChocolate.Authorization |
| 109 | + MetadataReference.CreateFromFile(typeof(Authorization.AuthorizeAttribute).Assembly.Location), |
| 110 | + |
| 111 | + // HotChocolate.Types.OffsetPagination |
| 112 | + MetadataReference.CreateFromFile(typeof(UseOffsetPagingAttribute).Assembly.Location) |
| 113 | + ]; |
| 114 | +} |
0 commit comments