mirror of
https://github.com/AlexMacocian/Net.Sdk.Web.Extensions.git
synced 2026-07-15 13:39:29 +00:00
Opt out of optimization to fix optimization and trimming issues in NativeAOT
This commit is contained in:
@@ -14,6 +14,7 @@ public static class Constants
|
|||||||
public const string Default = "default";
|
public const string Default = "default";
|
||||||
public const string Namespace = "Net.Sdk.Web";
|
public const string Namespace = "Net.Sdk.Web";
|
||||||
public const string UsingSystemThreading = "System.Threading";
|
public const string UsingSystemThreading = "System.Threading";
|
||||||
|
public const string UsingSystemRuntimeCompilerServices = "System.Runtime.CompilerServices";
|
||||||
public const string UsingMicrosoftAspNetCoreHttp = "Microsoft.AspNetCore.Http";
|
public const string UsingMicrosoftAspNetCoreHttp = "Microsoft.AspNetCore.Http";
|
||||||
public const string UsingMicrosoftAspNetCoreRouting = "Microsoft.AspNetCore.Routing";
|
public const string UsingMicrosoftAspNetCoreRouting = "Microsoft.AspNetCore.Routing";
|
||||||
public const string UsingMicrosoftAspNetCoreBuilder = "Microsoft.AspNetCore.Builder";
|
public const string UsingMicrosoftAspNetCoreBuilder = "Microsoft.AspNetCore.Builder";
|
||||||
@@ -81,4 +82,7 @@ public static class Constants
|
|||||||
|
|
||||||
public const string T = "T";
|
public const string T = "T";
|
||||||
public const string IEndpointFilterName = "IEndpointFilter";
|
public const string IEndpointFilterName = "IEndpointFilter";
|
||||||
|
|
||||||
|
public const string MethodImplAttribute = "MethodImpl";
|
||||||
|
public const string MethodImplArgument = "MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization | MethodImplOptions.PreserveSig";
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<Version>0.8.19</Version>
|
<Version>0.8.20</Version>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>Alexandru Macocian</Authors>
|
<Authors>Alexandru Macocian</Authors>
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.9.0" PrivateAssets="all" />
|
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.9.0" PrivateAssets="all" />
|
||||||
<PackageReference Include="Sybil" Version="0.8.3" PrivateAssets="all" />
|
<PackageReference Include="Sybil" Version="0.8.4" PrivateAssets="all" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using System.Collections.Generic;
|
|||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Net.Sdk.Web.Extensions.SourceGenerators;
|
namespace Net.Sdk.Web.Extensions.SourceGenerators;
|
||||||
@@ -72,7 +73,8 @@ public class UseRoutesGenerator : IIncrementalGenerator
|
|||||||
.WithUsing(Constants.UsingMicrosoftAspNetCoreRouting)
|
.WithUsing(Constants.UsingMicrosoftAspNetCoreRouting)
|
||||||
.WithUsing(Constants.UsingMicrosoftAspNetCoreHttp)
|
.WithUsing(Constants.UsingMicrosoftAspNetCoreHttp)
|
||||||
.WithUsing(Constants.UsingMicrosoftAspNetCoreBuilder)
|
.WithUsing(Constants.UsingMicrosoftAspNetCoreBuilder)
|
||||||
.WithUsing(Constants.UsingMicrosoftAspNetCoreMvc);
|
.WithUsing(Constants.UsingMicrosoftAspNetCoreMvc)
|
||||||
|
.WithUsing(Constants.UsingSystemRuntimeCompilerServices);
|
||||||
|
|
||||||
var routeUsings = new HashSet<string>();
|
var routeUsings = new HashSet<string>();
|
||||||
|
|
||||||
@@ -83,7 +85,9 @@ public class UseRoutesGenerator : IIncrementalGenerator
|
|||||||
namespaceBuilder.WithClass(webAppBuilder);
|
namespaceBuilder.WithClass(webAppBuilder);
|
||||||
var useRoutesWebAppMethodBuilder = SyntaxBuilder.CreateMethod(Constants.WebApplicationTypeName, Constants.UseRoutesMethodName)
|
var useRoutesWebAppMethodBuilder = SyntaxBuilder.CreateMethod(Constants.WebApplicationTypeName, Constants.UseRoutesMethodName)
|
||||||
.WithThisParameter(Constants.WebApplicationTypeName, Constants.BuilderParameterName)
|
.WithThisParameter(Constants.WebApplicationTypeName, Constants.BuilderParameterName)
|
||||||
.WithModifiers($"{Constants.Public} {Constants.Static}");
|
.WithModifiers($"{Constants.Public} {Constants.Static}")
|
||||||
|
.WithAttribute(SyntaxBuilder.CreateAttribute(Constants.MethodImplAttribute)
|
||||||
|
.WithRawArgument(Constants.MethodImplArgument));
|
||||||
webAppBuilder.WithMethod(useRoutesWebAppMethodBuilder);
|
webAppBuilder.WithMethod(useRoutesWebAppMethodBuilder);
|
||||||
|
|
||||||
var useRoutesWebAppBody = new StringBuilder();
|
var useRoutesWebAppBody = new StringBuilder();
|
||||||
|
|||||||
Reference in New Issue
Block a user