Skip to content

Fix bugs in ResourceCodeDomSerializer.SerializationResourceManager#9642

Merged
Tanya-Solyanik merged 2 commits intodotnet:mainfrom
halgab:SerializationResourceManager-fix
Aug 14, 2023
Merged

Fix bugs in ResourceCodeDomSerializer.SerializationResourceManager#9642
Tanya-Solyanik merged 2 commits intodotnet:mainfrom
halgab:SerializationResourceManager-fix

Conversation

@halgab
Copy link
Copy Markdown
Contributor

@halgab halgab commented Aug 3, 2023

As discussed in #9457.

#8332 introduced bugs in ResourceCodeDomSerializer.SerializationResourceManager, in method GetResourceSet. When we fail to get a resource reader, the original code used to return a resource set for the invariant culture, and null otherwise. After #8332,,

  • we're returning null the first time we fill the ResourceTable cache
  • for the non-invariant culture case, we started filling the ResourceTable cache with a static dictionary, which looks like a pretty big issue

These bugs were introduced in .Net 8 and we still have a chance to fix them before the release

@dreddy-work, @elachlan

Microsoft Reviewers: Open in CodeFlow

@halgab halgab requested a review from a team as a code owner August 3, 2023 07:45
@ghost ghost assigned halgab Aug 3, 2023
@halgab halgab changed the title Fix bug in ResourceCodeDomSerializer.SerializationResourceManager Fix bugs in ResourceCodeDomSerializer.SerializationResourceManager Aug 3, 2023
@halgab halgab force-pushed the SerializationResourceManager-fix branch from b32ec97 to ce56fa6 Compare August 3, 2023 09:05
@halgab halgab force-pushed the SerializationResourceManager-fix branch from ce56fa6 to b775f92 Compare August 3, 2023 09:09
@dreddy-work
Copy link
Copy Markdown
Member

  • we started filling the ResourceTable cache with a static dictionary, which looks like a pretty big issue

@halgab, i see original code before @elachlan's change was also doing this. Can you point me to the original code where it wasn't?

@dreddy-work dreddy-work added the waiting-author-feedback The team requires more information from the author label Aug 3, 2023
@halgab
Copy link
Copy Markdown
Contributor Author

halgab commented Aug 3, 2023

Before #8332, s_resourceSetSentinel was not a dictionary or a hashtable but an object (see line 21). Then on line 505, we checked that the content of ResourceTable was actually a Hashtable, which proved to be false when we were returning s_resourceSetSentinel. The assert on line 509 is here to support the fact that if ResourceTable returned anything but a Hashtable, then it must be s_resourceSetSentinel

@ghost ghost removed the waiting-author-feedback The team requires more information from the author label Aug 3, 2023
@Tanya-Solyanik
Copy link
Copy Markdown
Contributor

@halgab - is it possible to add a unit test for this scenario?

@halgab
Copy link
Copy Markdown
Contributor Author

halgab commented Aug 4, 2023

I agree that would be ideal, but right now code coverage of serializers is so scarce I wouldn't really know where to start...

@dreddy-work
Copy link
Copy Markdown
Member

We can track test debt under separate issue. @Tanya-Solyanik, you good with changes here?

@elachlan
Copy link
Copy Markdown
Contributor

elachlan commented Aug 7, 2023

Related: #719, #966

Copy link
Copy Markdown
Member

@lonitra lonitra left a comment

Choose a reason for hiding this comment

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

LGTM

@Tanya-Solyanik Tanya-Solyanik merged commit c3bf1fe into dotnet:main Aug 14, 2023
@ghost ghost added this to the 8.0 RC1 milestone Aug 14, 2023
@halgab halgab deleted the SerializationResourceManager-fix branch August 15, 2023 06:04
@ghost ghost locked as resolved and limited conversation to collaborators Sep 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants