-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add public ctor for SubscriptionValidationResponse #21975
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,9 +8,10 @@ | |
using System.Net.Http; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Azure.Messaging.EventGrid.SystemEvents; | ||
using Microsoft.Extensions.Logging; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using STJ = System.Text.Json; | ||
|
||
namespace Microsoft.Azure.WebJobs.Extensions.EventGrid | ||
{ | ||
|
@@ -69,7 +70,8 @@ internal async Task<HttpResponseMessage> ProcessAsync( | |
SubscriptionValidationResponse validationResponse = new(){ ValidationResponse = validationCode }; | ||
var returnMessage = new HttpResponseMessage(HttpStatusCode.OK) | ||
{ | ||
Content = new StringContent(JsonConvert.SerializeObject(validationResponse)) | ||
// use System.Text.Json to leverage the custom converter so that the casing is correct. | ||
Content = new StringContent(STJ.JsonSerializer.Serialize(validationResponse)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean the behavior of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, previously we were using a ValidationResponse model defined in the extension library which had a JsonProperty attribute to get camel casing. Now, we are using STJ converter which uses camel casing. I couldn't continue to use NewtonSoft and use the Event Grid SDK model. It seemed worth using the SDK model here to validate that it works. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW I tested it out and both Pascal and camelCase work fine when adding a subscription, but in order to maintain the same behavior as before (and to make the tests pass) it seems better to use camel case. |
||
}; | ||
_logger.LogInformation($"perform handshake with eventGrid for function: {functionName}"); | ||
return returnMessage; | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to hide the factory? I get that you can use the constructor directly but it feels nice to be able to create any model from the model factory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to, but it would go against our pattern of only including factories for output models. Codegen no longer generates the model factory for this type, so I had to add it back manually.
/cc @tg-msft @KrzysztofCwalina
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - the model factory only exists for constructing the otherwise unconstructible per the guidelines today: https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-mocking-factory-builder
It would take nontrivial effort to design and implement this across all of Track 2 when there's already a way of accomplishing it now, so it's not a high priority to me.