Skip to content

Commit 5386869

Browse files
authored
Annotate Azure.Storage.Blobs for trim/AOT compat (#46607)
* Annotate Azure.Storage.Blobs for trim/AOT compat * Fix apicompat * Fix trim warning message
1 parent f868683 commit 5386869

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

sdk/storage/Azure.Storage.Blobs/api/Azure.Storage.Blobs.net6.0.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,6 +1998,7 @@ public static partial class BlobClientBuilderExtensions
19981998
public static Azure.Core.Extensions.IAzureClientBuilder<Azure.Storage.Blobs.BlobServiceClient, Azure.Storage.Blobs.BlobClientOptions> AddBlobServiceClient<TBuilder>(this TBuilder builder, string connectionString) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilder { throw null; }
19991999
public static Azure.Core.Extensions.IAzureClientBuilder<Azure.Storage.Blobs.BlobServiceClient, Azure.Storage.Blobs.BlobClientOptions> AddBlobServiceClient<TBuilder>(this TBuilder builder, System.Uri serviceUri) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithCredential { throw null; }
20002000
public static Azure.Core.Extensions.IAzureClientBuilder<Azure.Storage.Blobs.BlobServiceClient, Azure.Storage.Blobs.BlobClientOptions> AddBlobServiceClient<TBuilder>(this TBuilder builder, System.Uri serviceUri, Azure.Storage.StorageSharedKeyCredential sharedKeyCredential) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilder { throw null; }
2001+
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Binding strongly typed objects to configuration values is not supported with trimming. Use the Configuration Binder Source Generator (EnableConfigurationBindingGenerator=true) instead.")]
20012002
public static Azure.Core.Extensions.IAzureClientBuilder<Azure.Storage.Blobs.BlobServiceClient, Azure.Storage.Blobs.BlobClientOptions> AddBlobServiceClient<TBuilder, TConfiguration>(this TBuilder builder, TConfiguration configuration) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithConfiguration<TConfiguration> { throw null; }
20022003
}
20032004
}

sdk/storage/Azure.Storage.Blobs/src/Azure.Storage.Blobs.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
REST API Reference for Blob Service - https://docs.microsoft.com/en-us/rest/api/storageservices/blob-service-rest-api
2020
</Description>
2121
<IncludeOperationsSharedSource>true</IncludeOperationsSharedSource>
22+
<IsTrimmable Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">true</IsTrimmable>
23+
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">true</IsAotCompatible>
2224
</PropertyGroup>
2325
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
2426
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

sdk/storage/Azure.Storage.Blobs/src/BlobClientBuilderExtensions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

44
using System;
5+
using System.Diagnostics.CodeAnalysis;
56
using Azure.Core.Extensions;
67
using Azure.Storage;
78
using Azure.Storage.Blobs;
@@ -45,6 +46,8 @@ public static IAzureClientBuilder<BlobServiceClient, BlobClientOptions> AddBlobS
4546
/// <summary>
4647
/// Registers a <see cref="BlobServiceClient"/> instance with connection options loaded from the provided <paramref name="configuration"/> instance.
4748
/// </summary>
49+
[RequiresUnreferencedCode("Binding strongly typed objects to configuration values is not supported with trimming. Use the Configuration Binder Source Generator (EnableConfigurationBindingGenerator=true) instead.")]
50+
[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.")]
4851
public static IAzureClientBuilder<BlobServiceClient, BlobClientOptions> AddBlobServiceClient<TBuilder, TConfiguration>(this TBuilder builder, TConfiguration configuration)
4952
where TBuilder : IAzureClientFactoryBuilderWithConfiguration<TConfiguration>
5053
{

sdk/storage/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,7 @@ extends:
7171
skipSmokeTests: true
7272
TestSetupSteps:
7373
- template: /sdk/storage/tests-install-azurite.yml
74+
CheckAOTCompat: true
75+
AOTTestInputs:
76+
- ArtifactName: Azure.Storage.Blobs
77+
ExpectedWarningsFilepath: None

0 commit comments

Comments
 (0)