Skip to content
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
10 changes: 8 additions & 2 deletions Modules/Reflection/GenHTTP.Modules.Reflection.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@
<ProjectReference Include="..\Conversion\GenHTTP.Modules.Conversion.csproj" />
<ProjectReference Include="..\Pages\GenHTTP.Modules.Pages.csproj" />

<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="5.9.0" />

<ProjectReference Include="..\..\Generators\MemoryView\GenHTTP.Generators.MemoryView.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />

</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net11.0'">
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="5.9.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net11.0'">
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="5.9.0" />
</ItemGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="" />
</ItemGroup>
Expand Down
13 changes: 11 additions & 2 deletions Modules/Reflection/Generation/DelegateProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using GenHTTP.Api.Content;
using GenHTTP.Api.Protocol;

using GenHTTP.Modules.IO;
using GenHTTP.Modules.Reflection.Operations;
using GenHTTP.Modules.Reflection.Routing;
Expand All @@ -24,6 +25,14 @@ internal static class DelegateProvider
deterministic: false
);

private static readonly CSharpParseOptions? ParseOptions =
#if NET11_0_OR_GREATER
new CSharpParseOptions(LanguageVersion.Preview)
.WithFeatures([new KeyValuePair<string, string>("runtime-async", "on")]);
#else
null;
#endif

private static bool _requirementsLoaded;

/// <summary>
Expand All @@ -35,7 +44,7 @@ internal static class DelegateProvider
/// <exception cref="InvalidOperationException">Thrown if the compilation failed for some reason</exception>
internal static Func<T, Operation, IRequest, IHandler, MethodRegistry, RoutingMatch, RequestInterception, ValueTask<IResponse?>> Compile<T>(string code)
{
var syntaxTree = CSharpSyntaxTree.ParseText(code);
var syntaxTree = CSharpSyntaxTree.ParseText(code, ParseOptions);

var assemblyName = Path.GetRandomFileName();

Expand Down Expand Up @@ -88,7 +97,7 @@ private static MetadataReference[] GetReferences()
_requirementsLoaded = true;
}

return References.Values.ToArray();
return [.. References.Values];
}

private static MetadataReference LoadAssembly(string fullName)
Expand Down
2 changes: 1 addition & 1 deletion Testing/Acceptance/GenHTTP.Testing.Acceptance.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<PackageReference Include="Microsoft.OpenApi" Version="3.10.2" />
<PackageReference Include="Microsoft.OpenApi.YamlReader" Version="3.10.2" />

<PackageReference Include="MSTest" Version="4.3.3" />
<PackageReference Include="MSTest" Version="4.4.0" />

<PackageReference Include="NSubstitute" Version="6.2.0" />

Expand Down
Loading