private void Initialize() { LazyInitializer.EnsureInitialized(ref initializationTarget, () => { // Setup the factories ConfigurationSettings.SetConfigurationFactory(ConfigurationFactory); Codec.SetCodecFactory(CodecFactory); DocValuesFormat.SetDocValuesFormatFactory(DocValuesFormatFactory); PostingsFormat.SetPostingsFormatFactory(PostingsFormatFactory); // Enable "asserts" for tests. In Java, these were actual asserts, // but in .NET we simply mock this as a boolean static setting that can be // toggled on and off, even in release mode. Note this must be done after // the ConfigurationFactory is set. Lucene.Net.Diagnostics.Debugging.AssertsEnabled = SystemProperties.GetPropertyAsBoolean("assert", true); IncrementInitalizationCount(); // For testing return(new object()); // Placeholder to indicate our initializer has been run already }); }
private void Initialize() { LazyInitializer.EnsureInitialized(ref initializationTarget, () => { // Setup the factories ConfigurationSettings.SetConfigurationFactory(ConfigurationFactory); Codec.SetCodecFactory(CodecFactory); DocValuesFormat.SetDocValuesFormatFactory(DocValuesFormatFactory); PostingsFormat.SetPostingsFormatFactory(PostingsFormatFactory); // Enable "asserts" for tests. In Java, these were actual asserts, // but in .NET we simply mock this as a boolean static setting that can be // toggled on and off, even in release mode. Note this must be done after // the ConfigurationFactory is set. Lucene.Net.Diagnostics.Debugging.AssertsEnabled = SystemProperties.GetPropertyAsBoolean("assert", true); // Identify NUnit exceptions down in Lucene.Net so they can be ignored in catch blocks that // catch Java "Exception" types that do subclass Error (for the ExceptionExtensions.IsException() method). Lucene.ExceptionExtensions.NUnitResultStateExceptionType = typeof(NUnit.Framework.ResultStateException); Lucene.ExceptionExtensions.NUnitAssertionExceptionType = typeof(NUnit.Framework.AssertionException); Lucene.ExceptionExtensions.NUnitMultipleAssertExceptionType = typeof(NUnit.Framework.MultipleAssertException); Lucene.ExceptionExtensions.NUnitInconclusiveExceptionType = typeof(NUnit.Framework.InconclusiveException); Lucene.ExceptionExtensions.NUnitSuccessExceptionType = typeof(NUnit.Framework.SuccessException); Lucene.ExceptionExtensions.NUnitInvalidPlatformException = Type.GetType("NUnit.Framework.Internal.InvalidPlatformException, NUnit.Framework"); // Identify the Debug.Assert() exception so it can be excluded from being swallowed by catch blocks. // These types are internal, so we can identify them using Reflection. Lucene.ExceptionExtensions.DebugAssertExceptionType = // .NET 5/.NET Core 3.x Type.GetType("System.Diagnostics.DebugProvider+DebugAssertException, System.Private.CoreLib") // .NET Core 2.x ?? Type.GetType("System.Diagnostics.Debug+DebugAssertException, System.Private.CoreLib"); // .NET Framework doesn't throw in this case AfterInitialization(); return(new object()); // Placeholder to indicate our initializer has been run already }); }