Skip to content
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

Remove static logging and replacing with DI-friendly system #483

Merged
merged 11 commits into from
Feb 2, 2023

Commits on Feb 1, 2023

  1. WIP: First pass at removing static logging and replacing with a more …

    …DI approach for #455
    
    Attempted as much as possible to break few contracts, and provide forwarding to new implementation
    
    Removed dependence on Microsoft.Extensions.Logging, but added Microsoft.Extensions.DependencyInjection
    
    Works by introducing an internal DI ServiceCollection and ServiceProvider available via a singleton resource. This collection can be configured by a consumer, but services will work out the box without any config (just with Null Logging)
    
    Consumers can add own logging, either with AddLogging(), or by telliing xbim to UseLoggerFactory(logFactory).
    
    Removed public Setter ILoggers. Because we're not fully in control of DI composition favoured approach is to inject/pass in ILoggerFactory to key roots. We're using ServiceLocator anti-pattern in other cases as a last resort.
    
    ModelProvider & Factory has been re-worked to actually work with DI.
    
    One subtle change - Previosuly Heuristic ModelProvider kicked in if Esent was loaded. Now that needs to be set explicitly when configuring the app.
    
    i.e. XbimServices.Current.ConfigureServices(s => s.AddXbimToolkit(opt => opt.UseHeuristicModel()));
    
    Legacy 'DI lite' concepts like IfcStore.ModelProviderFactory.UseHeuristicModelProvider() have been remapped to a new approach and Obsoleted.
    
    TODO: many tests use the old obsoleted overloads, which forward onto new .
    All tests pass (with one flaky IfcStore ModelProvider test to resolve)
    andyward committed Feb 1, 2023
    Configuration menu
    Copy the full SHA
    4cdaf8b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    4828878 View commit details
    Browse the repository at this point in the history
  3. Fix up brittle tests

    Caused by random sequencing of tests and shared state
    andyward committed Feb 1, 2023
    Configuration menu
    Copy the full SHA
    daf34bb View commit details
    Browse the repository at this point in the history
  4. Streamline upgrade experience

    Fixed up defaults on obsolete methods so typical upgraders will auto pick up new implementations by default. i.e. will default to ILoggerFactory signature over ILogger when caller didn't provide any logger
    Addresses all test warnings except Scanner
    andyward committed Feb 1, 2023
    Configuration menu
    Copy the full SHA
    1315fd5 View commit details
    Browse the repository at this point in the history

Commits on Feb 2, 2023

  1. Esent model now included in Xbim.Ifc again so we don't default to Mem…

    …oryModel.
    
    Added some guards/logging to Esent & Heurisrstic ModelProvider infrastructure when used under non WIndows o/s
    andyward committed Feb 2, 2023
    Configuration menu
    Copy the full SHA
    b3fce6f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    28ca0a4 View commit details
    Browse the repository at this point in the history
  3. Removed all ILoggerFactory params on static factory methods.

    Replaced by ServiceLocator
    
    None-breaking as these were only added lately after obsoleting the equivalent ILogger param methods and related DI work
    andyward committed Feb 2, 2023
    Configuration menu
    Copy the full SHA
    313b7b4 View commit details
    Browse the repository at this point in the history
  4. Address random failung tests

    We're mix & match xUnit and vsTest... xUnit classes need Bootstrapping reliably or sequencing issues can trigger failures in singleton state
    andyward committed Feb 2, 2023
    Configuration menu
    Copy the full SHA
    9c431d2 View commit details
    Browse the repository at this point in the history
  5. Removed DefaultModelProviderFactory completely

    Made redundant by DI
    andyward committed Feb 2, 2023
    Configuration menu
    Copy the full SHA
    049b8dc View commit details
    Browse the repository at this point in the history
  6. Final Tidy

    andyward committed Feb 2, 2023
    Configuration menu
    Copy the full SHA
    3bd3525 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    bf1d932 View commit details
    Browse the repository at this point in the history