Uploaded image for project: 'Lucene.Net'
  1. Lucene.Net
  2. LUCENENET-642

Eliminate Runtime Reflection Code from TokenStream

    XMLWordPrintableJSON

Details

    • Task
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • Lucene.Net 4.8.0
    • Lucene.Net 4.8.0
    • Lucene.Net Core
    • None

    Description

      As per LUCENENET-640, the TokenStream.AssertFinal method is causing performance issues. This method was used to assert that the usage of TokenStream is correct - that is, subclasses or their IncrementToken() method must be sealed.

      In Java, there is not a performance issue because asserts are presumably turned off in production applications and the Reflection overhead only happens when debugging. However, in .NET asserts are compiled out of the final release so doing it in a similar way would disable the feature for end users.

      Instead, we should create Rosnlyn code analyzers to ensure the project doesn't compile unless the end user seals either the class or its IncrementToken() method. This effectively means we leave the heavy code analysis up to the IDE/build and it doesn't run at all in production.

      Per this article, it is feasible to package a code analyzer into the Lucene.Net NuGet package so when it is installed the code analysis will take effect in the IDE.

      Attachments

        Issue Links

          Activity

            People

              nightowl888 Shad Storhaug
              nightowl888 Shad Storhaug
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 10h
                  10h
                  Remaining:
                  Remaining Estimate - 10h
                  10h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified