Skip to content

Commit cde4aca

Browse files
rogerbarretoCopilot
andcommitted
Suppress IL2026/IL3050 with targeted pragmas on affected methods
Add #pragma warning disable/restore for IL2026 and IL3050 only around the specific methods where dotnet format incorrectly adds [RequiresUnreferencedCode] and [RequiresDynamicCode] attributes despite proper interceptors configuration in the csproj. See dotnet/sdk#51136 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1b76681 commit cde4aca

4 files changed

Lines changed: 15 additions & 0 deletions

File tree

dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/AGUIEndpointRouteBuilderExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public static class AGUIEndpointRouteBuilderExtensions
2828
/// <param name="pattern">The URL pattern for the endpoint.</param>
2929
/// <param name="aiAgent">The agent instance.</param>
3030
/// <returns>An <see cref="IEndpointConventionBuilder"/> for the mapped endpoint.</returns>
31+
// Workaround: dotnet format does not respect IL2026/IL3050 with interceptors configuration. See https://github.com/dotnet/sdk/issues/51136
32+
#pragma warning disable IL2026, IL3050
3133
public static IEndpointConventionBuilder MapAGUI(
3234
this IEndpointRouteBuilder endpoints,
3335
[StringSyntax("route")] string pattern,
@@ -80,4 +82,5 @@ public static IEndpointConventionBuilder MapAGUI(
8082
return new AGUIServerSentEventsResult(events, sseLogger);
8183
});
8284
}
85+
#pragma warning restore IL2026, IL3050
8386
}

dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/EndpointRouteBuilderExtensions.ChatCompletions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public static IEndpointConventionBuilder MapOpenAIChatCompletions(this IEndpoint
4949
/// <param name="endpoints">The <see cref="IEndpointRouteBuilder"/> to add the OpenAI ChatCompletions endpoints to.</param>
5050
/// <param name="agent">The <see cref="AIAgent"/> instance to map the OpenAI ChatCompletions endpoints for.</param>
5151
/// <param name="path">Custom route path for the chat completions endpoint.</param>
52+
// Workaround: dotnet format does not respect IL2026/IL3050 with interceptors configuration. See https://github.com/dotnet/sdk/issues/51136
53+
#pragma warning disable IL2026, IL3050
5254
public static IEndpointConventionBuilder MapOpenAIChatCompletions(
5355
this IEndpointRouteBuilder endpoints,
5456
AIAgent agent,
@@ -69,4 +71,5 @@ public static IEndpointConventionBuilder MapOpenAIChatCompletions(
6971

7072
return group;
7173
}
74+
#pragma warning restore IL2026, IL3050
7275
}

dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/EndpointRouteBuilderExtensions.Conversations.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public static partial class MicrosoftAgentAIHostingOpenAIEndpointRouteBuilderExt
1717
/// Maps OpenAI Conversations API endpoints to the specified <see cref="IEndpointRouteBuilder"/>.
1818
/// </summary>
1919
/// <param name="endpoints">The <see cref="IEndpointRouteBuilder"/> to add the OpenAI Conversations endpoints to.</param>
20+
// Workaround: dotnet format does not respect IL2026/IL3050 with interceptors configuration. See https://github.com/dotnet/sdk/issues/51136
21+
#pragma warning disable IL2026, IL3050
2022
public static IEndpointConventionBuilder MapOpenAIConversations(this IEndpointRouteBuilder endpoints)
2123
{
2224
ArgumentNullException.ThrowIfNull(endpoints);
@@ -70,4 +72,5 @@ public static IEndpointConventionBuilder MapOpenAIConversations(this IEndpointRo
7072

7173
return group;
7274
}
75+
#pragma warning restore IL2026, IL3050
7376
}

dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/EndpointRouteBuilderExtensions.Responses.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public static IEndpointConventionBuilder MapOpenAIResponses(this IEndpointRouteB
5555
/// <param name="endpoints">The <see cref="IEndpointRouteBuilder"/> to add the OpenAI Responses endpoints to.</param>
5656
/// <param name="agent">The <see cref="AIAgent"/> instance to map the OpenAI Responses endpoints for.</param>
5757
/// <param name="responsesPath">Custom route path for the responses endpoint.</param>
58+
// Workaround: dotnet format does not respect IL2026/IL3050 with interceptors configuration. See https://github.com/dotnet/sdk/issues/51136
59+
#pragma warning disable IL2026, IL3050
5860
public static IEndpointConventionBuilder MapOpenAIResponses(
5961
this IEndpointRouteBuilder endpoints,
6062
AIAgent agent,
@@ -105,6 +107,7 @@ public static IEndpointConventionBuilder MapOpenAIResponses(
105107

106108
return group;
107109
}
110+
#pragma warning restore IL2026, IL3050
108111

109112
/// <summary>
110113
/// Maps OpenAI Responses API endpoints to the specified <see cref="IEndpointRouteBuilder"/>.
@@ -118,6 +121,8 @@ public static IEndpointConventionBuilder MapOpenAIResponses(this IEndpointRouteB
118121
/// </summary>
119122
/// <param name="endpoints">The <see cref="IEndpointRouteBuilder"/> to add the OpenAI Responses endpoints to.</param>
120123
/// <param name="responsesPath">Custom route path for the responses endpoint.</param>
124+
// Workaround: dotnet format does not respect IL2026/IL3050 with interceptors configuration. See https://github.com/dotnet/sdk/issues/51136
125+
#pragma warning disable IL2026, IL3050
121126
public static IEndpointConventionBuilder MapOpenAIResponses(
122127
this IEndpointRouteBuilder endpoints,
123128
[StringSyntax("Route")] string? responsesPath)
@@ -158,6 +163,7 @@ public static IEndpointConventionBuilder MapOpenAIResponses(
158163

159164
return group;
160165
}
166+
#pragma warning restore IL2026, IL3050
161167

162168
private static void ValidateAgentName([NotNull] string agentName)
163169
{

0 commit comments

Comments
 (0)