Skip to content

Commit baa481b

Browse files
Migrate Event Grid Namespaces to new generator (Azure#49948)
* wip * WIP * wip * Migrate to new generator * Regen * Add baseline * Delete usings * change log * version * regen
1 parent f86a2f5 commit baa481b

File tree

92 files changed

+4185
-4143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+4185
-4143
lines changed

sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/CHANGELOG.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
# Release History
22

3-
## 1.1.0-beta.1 (Unreleased)
3+
## 1.1.0 (2025-05-09)
44

55
### Features Added
66

77
- Exposed `JsonModelWriteCore` for model serialization procedure.
88

9-
### Breaking Changes
10-
119
### Bugs Fixed
1210

13-
### Other Changes
11+
- Add tracing information to CloudEvents when tracing is enabled.
1412

1513
## 1.0.0 (2024-06-11)
1614

sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/api/Azure.Messaging.EventGrid.Namespaces.net8.0.cs

Lines changed: 40 additions & 0 deletions
Large diffs are not rendered by default.

sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/api/Azure.Messaging.EventGrid.Namespaces.netstandard2.0.cs

Lines changed: 40 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This attribute is now generated in each library. There should be no impact to end users.
2+
CannotRemoveAttribute : Attribute 'Azure.Core.CodeGenSerializationAttribute' exists on 'Azure.Messaging.EventGrid.Namespaces.ReceiveDetails' in the contract but not the implementation.

sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Azure.Messaging.EventGrid.Namespaces.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<Description>Azure Event Grid is a publish-subscribe service that allows cloud events to be passed from producers to consumers. This client library allows for both publishing and consuming events using Azure Event Grid. For more information about Event Grid, see https://azure.microsoft.com/services/event-grid.</Description>
44
<AssemblyTitle>Azure EventGrid Namespaces client library</AssemblyTitle>
5-
<Version>1.1.0-beta.1</Version>
5+
<Version>1.1.0</Version>
66
<!--The ApiCompatVersion is managed automatically and should not generally be modified manually.-->
77
<ApiCompatVersion>1.0.0</ApiCompatVersion>
88
<PackageTags>Azure;Event Grid;CloudEvent;$(PackageCommonTags)</PackageTags>

sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Customization/AzureMessagingEventGridNamespacesClientOptions.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.

sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Customization/CloudEvent.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
using Azure.Core;
5-
64
namespace Azure.Messaging.EventGrid.Namespaces
75
{
86
// make this type internal because it should be replaced by Azure.Messaging.CloudEvent from Azure.Core assembly
97
// rename it so as to not conflict with the CloudEvent type in Azure.Core so that samples can be more user friendly
10-
[CodeGenModel("CloudEvent")]
8+
[CodeGenType("CloudEvent")]
119
internal partial class CloudEventInternal
1210
{
1311
}

sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Customization/EventGridNamespacesModelFactory.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
using Azure.Core;
5-
64
namespace Azure.Messaging.EventGrid.Namespaces
75
{
8-
[CodeGenModel("MessagingEventGridNamespacesModelFactory")]
6+
[CodeGenType("AzureMessagingEventGridNamespacesModelFactory")]
97
public static partial class EventGridNamespacesModelFactory
108
{
119
}

sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Customization/EventGridReceiverClient.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System;
55
using System.Collections.Generic;
66
using System.ComponentModel;
7-
using System.Linq;
87
using System.Threading;
98
using System.Threading.Tasks;
109
using Azure.Core;
@@ -14,8 +13,8 @@ namespace Azure.Messaging.EventGrid.Namespaces
1413
{
1514
[CodeGenSuppress("EventGridReceiverClient", typeof(Uri), typeof(AzureKeyCredential))]
1615
[CodeGenSuppress("EventGridReceiverClient", typeof(Uri), typeof(TokenCredential))]
17-
[CodeGenSuppress("EventGridReceiverClient", typeof(Uri), typeof(AzureKeyCredential), typeof(AzureMessagingEventGridNamespacesClientOptions))]
18-
[CodeGenSuppress("EventGridReceiverClient", typeof(Uri), typeof(TokenCredential), typeof(AzureMessagingEventGridNamespacesClientOptions))]
16+
[CodeGenSuppress("EventGridReceiverClient", typeof(Uri), typeof(AzureKeyCredential), typeof(EventGridReceiverClientOptions))]
17+
[CodeGenSuppress("EventGridReceiverClient", typeof(Uri), typeof(TokenCredential), typeof(EventGridReceiverClientOptions))]
1918
public partial class EventGridReceiverClient
2019
{
2120
private readonly string _topicName;
@@ -68,7 +67,7 @@ public EventGridReceiverClient(Uri endpoint,
6867

6968
ClientDiagnostics = new ClientDiagnostics(options, true);
7069
_keyCredential = credential;
71-
_pipeline = HttpPipelineBuilder.Build(options, Array.Empty<HttpPipelinePolicy>(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader, AuthorizationApiKeyPrefix) }, new ResponseClassifier());
70+
Pipeline = HttpPipelineBuilder.Build(options, Array.Empty<HttpPipelinePolicy>(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader, AuthorizationApiKeyPrefix) }, new ResponseClassifier());
7271
_endpoint = endpoint;
7372
_apiVersion = options.Version;
7473
_topicName = topicName;
@@ -96,7 +95,7 @@ public EventGridReceiverClient(Uri endpoint,
9695

9796
ClientDiagnostics = new ClientDiagnostics(options, true);
9897
_tokenCredential = credential;
99-
_pipeline = HttpPipelineBuilder.Build(options, Array.Empty<HttpPipelinePolicy>(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier());
98+
Pipeline = HttpPipelineBuilder.Build(options, Array.Empty<HttpPipelinePolicy>(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier());
10099
_endpoint = endpoint;
101100
_apiVersion = options.Version;
102101
_topicName = topicName;

sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Customization/EventGridSenderClient.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ namespace Azure.Messaging.EventGrid.Namespaces
1313
{
1414
[CodeGenSuppress("EventGridSenderClient", typeof(Uri), typeof(AzureKeyCredential))]
1515
[CodeGenSuppress("EventGridSenderClient", typeof(Uri), typeof(TokenCredential))]
16-
[CodeGenSuppress("EventGridSenderClient", typeof(Uri), typeof(AzureKeyCredential), typeof(AzureMessagingEventGridNamespacesClientOptions))]
17-
[CodeGenSuppress("EventGridSenderClient", typeof(Uri), typeof(TokenCredential), typeof(AzureMessagingEventGridNamespacesClientOptions))]
16+
[CodeGenSuppress("EventGridSenderClient", typeof(Uri), typeof(AzureKeyCredential), typeof(EventGridSenderClientOptions))]
17+
[CodeGenSuppress("EventGridSenderClient", typeof(Uri), typeof(TokenCredential), typeof(EventGridSenderClientOptions))]
1818
public partial class EventGridSenderClient
1919
{
2020
private readonly string _topicName;
@@ -63,7 +63,7 @@ public EventGridSenderClient(Uri endpoint,
6363

6464
ClientDiagnostics = new ClientDiagnostics(options, true);
6565
_keyCredential = credential;
66-
_pipeline = HttpPipelineBuilder.Build(options, Array.Empty<HttpPipelinePolicy>(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader, AuthorizationApiKeyPrefix) }, new ResponseClassifier());
66+
Pipeline = HttpPipelineBuilder.Build(options, Array.Empty<HttpPipelinePolicy>(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader, AuthorizationApiKeyPrefix) }, new ResponseClassifier());
6767
_endpoint = endpoint;
6868
_apiVersion = options.Version;
6969
_topicName = topicName;
@@ -91,7 +91,7 @@ public EventGridSenderClient(Uri endpoint,
9191

9292
ClientDiagnostics = new ClientDiagnostics(options, true);
9393
_tokenCredential = credential;
94-
_pipeline = HttpPipelineBuilder.Build(options, Array.Empty<HttpPipelinePolicy>(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier());
94+
Pipeline = HttpPipelineBuilder.Build(options, Array.Empty<HttpPipelinePolicy>(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier());
9595
_endpoint = endpoint;
9696
_apiVersion = options.Version;
9797
_topicName = topicName;
@@ -301,5 +301,16 @@ public virtual Response SendEvents(RequestContent content, RequestContext contex
301301
{
302302
return SendEvents(_topicName, content, context);
303303
}
304+
305+
private static RequestContext DefaultRequestContext = new RequestContext();
306+
internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default)
307+
{
308+
if (!cancellationToken.CanBeCanceled)
309+
{
310+
return DefaultRequestContext;
311+
}
312+
313+
return new RequestContext() { CancellationToken = cancellationToken };
314+
}
304315
}
305316
}

0 commit comments

Comments
 (0)