Skip to content

Commit

Permalink
Annotate Azure.Messaging.ServiceBus for trim/AOT compat (#47004)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbomer authored Nov 6, 2024
1 parent 3225889 commit 73d1124
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
$(NoWarn);CA2213
</NoWarn>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsTrimmable Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">true</IsTrimmable>
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">true</IsAotCompatible>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using Azure.Core.Extensions;
using Azure.Messaging.ServiceBus;
using Azure.Messaging.ServiceBus.Administration;
Expand Down Expand Up @@ -37,6 +38,8 @@ public static IAzureClientBuilder<ServiceBusClient, ServiceBusClientOptions> Add
/// Registers a <see cref="ServiceBusClient"/> instance with connection options loaded from the provided <paramref name="configuration"/> instance.
/// </summary>
///
[RequiresUnreferencedCode("Binding strongly typed objects to configuration values is not supported with trimming. Use the Configuration Binder Source Generator (EnableConfigurationBindingGenerator=true) instead.")]
[RequiresDynamicCode("Binding strongly typed objects to configuration values requires generating dynamic code at runtime, for example instantiating generic types. Use the Configuration Binder Source Generator (EnableConfigurationBindingGenerator=true) instead.")]
public static IAzureClientBuilder<ServiceBusClient, ServiceBusClientOptions> AddServiceBusClient<TBuilder, TConfiguration>(this TBuilder builder, TConfiguration configuration)
where TBuilder : IAzureClientFactoryBuilderWithConfiguration<TConfiguration>
{
Expand Down Expand Up @@ -78,6 +81,8 @@ public static IAzureClientBuilder<ServiceBusAdministrationClient, ServiceBusAdmi
/// Registers a <see cref="ServiceBusAdministrationClient"/> instance with connection options loaded from the provided <paramref name="configuration"/> instance.
/// </summary>
///
[RequiresUnreferencedCode("Binding strongly typed objects to configuration values is not supported with trimming. Use the Configuration Binder Source Generator (EnableConfigurationBindingGenerator=true) instead.")]
[RequiresDynamicCode("Binding strongly typed objects to configuration values requires generating dynamic code at runtime, for example instantiating generic types. Use the Configuration Binder Source Generator (EnableConfigurationBindingGenerator=true) instead.")]
public static IAzureClientBuilder<ServiceBusAdministrationClient, ServiceBusAdministrationClientOptions> AddServiceBusAdministrationClient<TBuilder, TConfiguration>(this TBuilder builder, TConfiguration configuration)
where TBuilder : IAzureClientFactoryBuilderWithConfiguration<TConfiguration>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Tracing;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -385,6 +386,7 @@ public virtual void PeekMessageStart(string identifier, long? sequenceNumber, in

[NonEvent]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026", Justification = EventSourceSuppressMessage)]
private unsafe void PeekMessageStartCore(int eventId, string identifier, long? sequenceNumber, int messageCount)
{
fixed (char* identifierPtr = identifier)
Expand Down Expand Up @@ -1094,6 +1096,7 @@ private void ProcessorMessageHandlerExceptionCore(string identifier, long sequen

[NonEvent]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026", Justification = EventSourceSuppressMessage)]
private unsafe void ProcessorMessageHandlerExceptionCore(int eventId, string identifier, long sequenceNumber, string exception, string lockToken)
{
fixed (char* identifierPtr = identifier)
Expand Down Expand Up @@ -1254,6 +1257,7 @@ public virtual void LinkStateLost(string identifier, string receiveLinkName, str

[NonEvent]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026", Justification = EventSourceSuppressMessage)]
private unsafe void LinkStateLostCore(int eventId, string identifier, string receiveLinkName, string receiveLinkState, bool isSessionReceiver, string exception)
{
fixed (char* identifierPtr = identifier)
Expand Down Expand Up @@ -1807,6 +1811,7 @@ public void TransactionDischarged(string transactionId, string amqpTransactionId

[NonEvent]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026", Justification = EventSourceSuppressMessage)]
private unsafe void TransactionDischargedCore(int eventId, string transactionId, string amqpTransactionId, bool rollback)
{
fixed (char* transactionIdPtr = transactionId)
Expand Down Expand Up @@ -1909,6 +1914,7 @@ public virtual void PartitionKeyOverwritten(string partitionKey, string sessionI
/// <param name="arg3">The third argument.</param>
[NonEvent]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026", Justification = EventSourceSuppressMessage)]
private unsafe void WriteEvent(int eventId, string arg1, int arg2, string arg3)
{
fixed (char* arg1Ptr = arg1)
Expand Down Expand Up @@ -1940,6 +1946,7 @@ private unsafe void WriteEvent(int eventId, string arg1, int arg2, string arg3)
/// <param name="arg3">The third argument.</param>
[NonEvent]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026", Justification = EventSourceSuppressMessage)]
private unsafe void WriteEvent(int eventId, string arg1, long arg2, string arg3)
{
fixed (char* arg1Ptr = arg1)
Expand Down Expand Up @@ -1971,6 +1978,7 @@ private unsafe void WriteEvent(int eventId, string arg1, long arg2, string arg3)
/// <param name="arg4">The fourth argument.</param>
[NonEvent]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026", Justification = EventSourceSuppressMessage)]
private unsafe void WriteEvent(int eventId, string arg1, string arg2, string arg3, string arg4)
{
fixed (char* arg1Ptr = arg1)
Expand Down
4 changes: 4 additions & 0 deletions sdk/servicebus/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ extends:
Artifacts:
- name: Azure.Messaging.ServiceBus
safeName: AzureMessagingServiceBus
CheckAotCompat: true
AOTTestInputs:
- ArtifactName: Azure.Messaging.ServiceBus
ExpectedWarningsFilepath: None

0 comments on commit 73d1124

Please sign in to comment.