Skip to content
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

Update message writer and reader to ignore Message info from DI #3058

Merged
merged 9 commits into from
Sep 23, 2024

Conversation

marabooy
Copy link
Member

@marabooy marabooy commented Sep 9, 2024

Removes calls to GetRequiredService as these instances are overwritten immediately.
Simplifies their creation to call stacks where they are needed.

habbes
habbes previously approved these changes Sep 9, 2024
mikepizzo
mikepizzo previously approved these changes Sep 9, 2024
habbes
habbes previously approved these changes Sep 9, 2024
@marabooy marabooy dismissed stale reviews from habbes and mikepizzo via ebdb79c September 9, 2024 18:11
@marabooy marabooy requested review from mikepizzo and habbes September 9, 2024 18:26
mikepizzo
mikepizzo previously approved these changes Sep 9, 2024
@@ -904,24 +904,18 @@ private ODataMessageInfo GetOrCreateMessageInfo(Stream messageStream, bool isAsy
{
if (this.messageInfo == null)
{
if (this.serviceProvider == null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strictly speaking, that could be a breaking change. The likelihood of breaking existing code is low, likely 0, but here's sample code that will break today if we removed ODataMessageInfo from the DI:

var serviceCollection = new ServiceCollection();
serviceCollection.AddDefaultODataServices();
var serviceProvider = serviceCollection.BuildServiceProvider();
var messageInfo = serviceProvider.GetRequiredService<ODataMessageInfo>();

In the current version, this would return a messageInfo instance, if we remove it from DI and ship a new version, then this code would suddenly throw an exception when the user updates.

If we want to be strict about non-breaking minor and patch releases, we can remove it from the next major version and consider making the class private.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be a breaking change but it seems it could have very few users since a search shows that this was only being used in that location. Also the DI version is scoped which should not reproduce this bug/issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/OData/odata.net/blob/main/buildandtest.yml#L24 this build step is the one that fails to build

habbes
habbes previously approved these changes Sep 11, 2024
Comment on lines +31 to +32
var content1 = string.Concat(Enumerable.Repeat('A', 1000_000));
var content2 = string.Concat(Enumerable.Repeat('B', 1000_000));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to create such long strings?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily but it would make the interleaving more apparent if it happens

habbes
habbes previously approved these changes Sep 23, 2024
@marabooy marabooy merged commit 43258f9 into main Sep 23, 2024
5 checks passed
@marabooy marabooy deleted the ft/remove-message-info-from-being-resolved-using-di branch September 23, 2024 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants