lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [lucenenet] NightOwl888 commented on issue #282: Docs - Build/Deploy Automation
Date Tue, 02 Jun 2020 09:54:50 GMT

NightOwl888 commented on issue #282:
URL: https://github.com/apache/lucenenet/issues/282#issuecomment-637429897


   Great. If that works, we can use it.
   
   However, I took a look at the source code and it seems that the UID functionality can be
overridden by injecting a custom `IAssemblySymbol` (which can be a decorator around the original).
While it will take more than just this one decorator to ensure that this can be injected,
the difficult part is getting to the point where the top level dependency can be overridden
to inject our custom decorators.
   
   I walked up the class dependencies:
   
   ```
   internal class RoslynMetadataExtractor (Inject IAssemblySymbol into constructor)
   public class RoslynIntermediateMetadataExtractor : IExtractor (Extract())
   public class RoslynSourceFileBuildController : IRoslynBuildController (ExtractMetadata())
   public sealed class ExtractMetadataWorker : IDisposable (SaveAllMembersFromCacheAsync())
   internal sealed class MetadataCommand : ISubCommand (Exec())
   
   [CommandOption("metadata", "Generate YAML files from source code")]
   internal sealed class MetadataCommandCreator : CommandCreator<MetadataCommandOptions,
MetadataCommand>
   {
       public override MetadataCommand CreateCommand(MetadataCommandOptions options, ISubCommandController
controller)
       {
           return new MetadataCommand(options);
       }
   }
   ```
   
   So, at the top level, we end up with an abstract factory, which is perfect for injecting
a custom class with dependencies. The command is being exported using the MEF `ExportAttribute`
which is subclassed by `CommandOptionAttribute`.
   
   I did a bit of research, and it seems that [adding an `ExportMetadataAttribute` can be
used to create a custom component with a higher priority than the original component](https://greenicicle.wordpress.com/2010/07/19/replacing-components-with-mef/)
in order to replace the built-in factory with a custom one.
   
   Ultimately, it is the [CompositionContainer](https://github.com/dotnet/docfx/blob/dev/src/Microsoft.DocAsCode.Build.Engine/CompositionContainer.cs)
that is responsible for resolving the instance of the `MetadataCommandCreator ` class, which
is what needs to be tested to verify that we can override the default `MetadataCommandCreator`
with a custom one. From that point, replacing and/or decorating the components with custom
ones is fairly straightforward.


----------------------------------------------------------------
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:
users@infra.apache.org



Mime
View raw message