Finish #123 - Fix sealed & visibility issues part2#125
Open
udlose wants to merge 8 commits intodanipen:masterfrom
Open
Finish #123 - Fix sealed & visibility issues part2#125udlose wants to merge 8 commits intodanipen:masterfrom
udlose wants to merge 8 commits intodanipen:masterfrom
Conversation
Refactored TMModel.cs to implement the recommended Dispose pattern: - Replaced original Dispose with public Dispose and protected virtual Dispose(bool). - Added detailed XML documentation for disposal methods. - Ensured managed resources are disposed only once via Interlocked.CompareExchange inside the isDisposing branch. - Moved resource cleanup logic to managed disposal section. - Suppressed finalization and enabled safe extension for derived classes. - Structure allows for future unmanaged resource handling.
Strengthen encapsulation and immutability Several classes changed from public to internal and sealed, with fields and methods updated to internal and readonly where appropriate. GrammarNames made static; SupportedGrammars is now readonly. These changes improve code safety and clarify usage boundaries.
Introduced CustomBenchmarksConfig to display memory usage in kilobytes for more precise measurement in benchmark summaries. Applied this config to BigFileTokenizationBenchmark via attribute. Cleaned up using statements and improved formatting.
Introduced AllocatedBytesColumn for detailed memory usage reporting in benchmark results. Updated CustomBenchmarksConfig to include this column and set summary style to kilobytes and current culture. Minor formatting and console message improvements.
Refactored variable naming for clarity. Replaced exception-based parsing with TryParse for integers and floats, providing more accurate error messages. Corrected grammar in integer error message.
Added InternalsVisibleTo for DynamicProxyGenAssembly2 in AssemblyInfo.cs, allowing internal members to be accessed by mocking frameworks such as Moq during unit testing. Existing access for TextMateSharp.Tests remains unchanged.
Apply signature parity with tm4e upstream per https://github.com/eclipse-tm4e/tm4e/tree/main/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/rule Restrict visibility and improve encapsulation Refactored multiple classes to be internal and/or sealed, limiting access to within the assembly. Updated constructors, properties, and methods for better encapsulation and immutability. Renamed methods to follow C# conventions. Made static fields in RuleId readonly. Converted ThemeReader to a static class. Removed ICompilePatternsResult.cs and merged its contents. These changes clarify API boundaries and enhance maintainability.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Finishes #123
This pull request introduces several improvements to encapsulation and immutability for internal classes, adds a custom benchmark configuration for memory measurement, and refactors code for clarity and correctness. The most important changes are grouped below by theme.
Benchmark enhancements
CustomBenchmarksConfig) and a new memory allocation column (AllocatedBytesColumn) inBigFileTokenizationBenchmark.csto provide more detailed memory usage reporting during benchmarks. [1] [2]Encapsulation and immutability improvements
AttributedScopeStack,BalancedBracketSelectors,BasicScopeAttributes,BasicScopeAttributesProvider,BeginEndRule,BeginWhileRule,CaptureRule,NameMatcher, andCompilePatternsResult) from public to internal or sealed, and made fields readonly where appropriate to improve encapsulation and immutability. [1] [2] [3] [4] [5] [6] [7] [8] [9]Refactoring for clarity and correctness
PList.csto use local variabletinstead oftext, improved error handling for integer and float parsing, and simplified exception handling. [1] [2]BasicScopeAttributesProviderwhere the wrong variable was used in a regex string join, now correctly joiningreversedScopes.getWhileWithResolvedBackReferencestoGetWhileWithResolvedBackReferencesfor consistency inBeginWhileRule. [1] [2]Internal visibility for testing
InternalsVisibleToforDynamicProxyGenAssembly2inAssemblyInfo.csto enable mocking and testing of internal members.Minor improvements
GrammarNamesto a static class and its array toreadonlyfor improved safety and clarity.