NightOwl888 opened a new pull request #484:
URL: https://github.com/apache/lucenenet/pull/484
This removes support for NLS. This feature allowed lazy-loading of localized
resource messages, but required the exceptions to accept an `IMessage` instance
instead of a string. This makes it very inconvenient to use the following
exception types in the `Lucene.Net.QueryParsers.Flexible` namespace:
- `Core.QueryNodeError`
- `Core.QueryNodeException`
- `Core.QueryNodeParseException`
- `Standard.Parser.ParseException`
These exceptions were refactored to accept a string message and to accept an
`innerException` so they can be properly re-thrown. It also allows users to
supply their own exception messages inline more easily with the option to use
resource files, if desired.
This also removes `Lucene.Net.Util.BundleResourceManagerFactory` and
`IResourceManagerFactory` which were to allow users to supply their own
`ResourceManger` instance based on the type passed.
`BundleResourceManagerFactory` and `NLS` were awkward to use because they
required a "Bundle" suffix on the resource that was added to the project and to
add a subclass of `NLS` with static fields even though Visual Studio already
generates one.
The following classes were removed from the
`Lucene.Net.QueryParsers.Flexible` namespace:
- `Messages.Message`
- `Messages.IMessage`
- `Messages.NLS`
- `Messages.INLSException`
The Java-like design was abandoned and `QueryParserMessages` was redesigned
to be similar to the auto-generated class for QueryParser, however it now uses
a class named `QueryParserResourceProvider` (which implements
`IResourceProvider`) that contains the fallback logic for supplying custom
`ResourceProvider` instances without any special constraints on the naming or
other conventions used for creating the resources. End users can supply their
own resources by setting the `IResourceProvider` at application startup. The
built-in implementation, `QueryParserResourceProvider` accepts zero to many
`ResourceManager` instances in its constructor, so supplying localized messages
is now as easy as:
```c#
QueryParserMessages.SetResourceProvider(
new QueryParserResourceProvider(SomeResource.ResourceManager,
SomeOtherResource.ResourceManager));
```
at application startup.
The old NLS tests were commented out, and tests were added for the new
features to confirm the fallback logic is working correctly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]