Attribute [Export] is exported twice
See original GitHub issueHere’s my config, I think everything except the last line is irrelevant to the issue at hand:
var container = new DependencyInjectionContainer(c => c.AutoRegisterUnknown = false);
container.Configure(c =>
{
// Register one ILogger per container with automatic job context
c.ExportFactory((IExportLocatorScope scope) => Log.ForContext("Job", scope.ScopeName))
.Lifestyle.SingletonPerScope();
c.ExportFactory(A).AsKeyed<IDbConnection>("a");
c.ExportFactory(B).AsKeyed<IDbConnection>("b");
c.AddInspector(new ConfigInspector());
// [Export] from this assembly
c.ExportAssemblyContaining<JobSchedulerService>().ExportAttributedTypes();
});
ExportAttributedTypes
does export all classes in my assembly that have [Export]
, or [ExportByInterfaces]
, etc.
But when I look at activation strategies, or simply at WhatDoIHave
output, I notice that all [Export]
exports are actually exported twice.
They have the AsType: XY
line listed twice for every type they are exported as.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
c# - Duplicate Exports
This explains your double exports. Guidelines can be found on section "Using a Custom Export Attribute" from MEF's Documentation in CodePlex ...
Read more >Why do field values change when exporting from QGIS?
I have a table with two fields which are defined as Double, with a Length of 20 and a Precision of 0. Some...
Read more >Popup shows the data twice when exporting a specific ...
I've got a problem when exporting a specific layer to OpenLayers with QGIS2Web. This specific layer is a Parcel or Lot and has...
Read more >Export Attributes
The Export Attributes function exports all selected attribute information from the current MAP Layer to a delimited text file—comma, semi-colon, space or tab ......
Read more >Does exporting a video twice in premiere pro create ...
Exporting a video twice in Premiere Pro may cause a slight decrease in quality, depending on the compression settings an. Continue reading.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @jods4
Version 8 is about removing deprecated code and deprecated targets, I’ll put together list of changes this weekend.
@ipjohnson I was reading the code trying to see if I can figure out why. This is a complex codebase so I might be completely off… but could it be:
CreateExportStrategiesForTypes
will process the types found in my assemblies. Notice that this method looks forIExportAttribute
and will add those types toexportTypes
right here: https://github.com/ipjohnson/Grace/blob/39d4afb781a4b3b1634d33c6fd6b1165aac633a7/src/Grace/DependencyInjection/Impl/ExportTypeSetConfiguration.cs#L357 Because we have types inexportTypes
, the method will then callCreateExportStrategyForType
, here: https://github.com/ipjohnson/Grace/blob/39d4afb781a4b3b1634d33c6fd6b1165aac633a7/src/Grace/DependencyInjection/Impl/ExportTypeSetConfiguration.cs#L373CreateExportStrategyForType
does two unfortunate things. It exports everything inexportTypes
, right here: https://github.com/ipjohnson/Grace/blob/39d4afb781a4b3b1634d33c6fd6b1165aac633a7/src/Grace/DependencyInjection/Impl/ExportTypeSetConfiguration.cs#L402 I think this might be our first AsType export Later it goes on to process attributes here: https://github.com/ipjohnson/Grace/blob/39d4afb781a4b3b1634d33c6fd6b1165aac633a7/src/Grace/DependencyInjection/Impl/ExportTypeSetConfiguration.cs#L421I’m skipping a few indirections and intermediate methods. The default
IActivationStrategyAttributeProcessor
will end up right here, insideProcessClassAttributes
: https://github.com/ipjohnson/Grace/blob/e6853c7fb3b23a27824b9b2e17ad860b9b4a403b/src/Grace/DependencyInjection/Impl/ActivationStrategyAttributeProcessor.cs#L126 I think this is where we are AsType exported for the second timeMaybe I found the reason why attributes are exported twice. I am not sure what the fix is, though.
Gut feeling is that
exportTypes
at step 1 should not conflate exported types and types that are of interest because they have attributes.