-
-
Notifications
You must be signed in to change notification settings - Fork 365
fix(JsonStringLocalizer): add type check prevent endless loop #4653
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
Conversation
|
Thanks for your PR, @izanhzh. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Reviewer's Guide by SourceryThis PR fixes an endless loop issue in the JsonStringLocalizer by adding a type check to prevent recursive calls. The implementation includes new test cases to verify the fix and modifications to the localizer's string retrieval logic. Sequence diagram for string retrieval in JsonStringLocalizersequenceDiagram
participant Client
participant JsonStringLocalizer
participant Utility
participant Localizer
Client->>JsonStringLocalizer: Request string
JsonStringLocalizer->>Utility: GetStringLocalizerFromService
Utility-->>JsonStringLocalizer: Return Localizer
JsonStringLocalizer->>JsonStringLocalizer: Check if Localizer is JsonStringLocalizer
alt Localizer is not JsonStringLocalizer
JsonStringLocalizer->>Localizer: GetLocalizerValueFromCache
Localizer-->>JsonStringLocalizer: Return value
else Localizer is JsonStringLocalizer
JsonStringLocalizer-->>Client: Return null or default
end
Class diagram for JsonStringLocalizer and related classesclassDiagram
class JsonStringLocalizer {
- string? ret
+ LocalizedString this[string name]
+ IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures)
}
class MockLocalizerFactory {
+ IStringLocalizer Create(Type resourceSource)
+ IStringLocalizer Create(string baseName, string location)
}
class MockLocalizerFactory2 {
- IServiceProvider _serviceProvider
+ MockLocalizerFactory2(IServiceProvider serviceProvider)
+ IStringLocalizer Create(Type resourceSource)
+ IStringLocalizer Create(string baseName, string location)
}
class MockStringLocalizer {
+ LocalizedString this[string name]
}
JsonStringLocalizer --> MockLocalizerFactory
JsonStringLocalizer --> MockLocalizerFactory2
MockLocalizerFactory2 --> IServiceProvider
MockLocalizerFactory2 --> MockLocalizerFactory
MockLocalizerFactory --> MockStringLocalizer
MockLocalizerFactory2 --> MockStringLocalizer
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @izanhzh - I've reviewed your changes - here's some feedback:
Overall Comments:
- Please provide more context in the PR description about the endless loop issue being fixed and how the changes address it. This helps future maintainers understand the changes without having to reference external links.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4653 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 620 620
Lines 27419 27419
Branches 3928 3928
=========================================
Hits 27419 27419 ☔ View full report in Codecov by Sentry. |
fix: #4652
在单元测试中我增加了一个
ValidateFixEndlessLoop方法,撤销掉我的代码调整,运行这个单元测试即可重现死循环问题