question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consider adding AllowRejection to formalize rejection

See original GitHub issue

Specifying AllowDefault on an import allows us to still instantiate the part being composed if that import is not found.

It would be useful to express the current semantics of rejection if AllowDefault is missing, but without causing an error in the composition. This would formalize the implicit expectation that the part will get rejected if the import is missing.

The big problem with rejection is it can have unforeseen consequences as it’s transitive. Also having errors in the composition is not great.

The Roslyn team has a usage scenario that goes like this:

We have [Export] components with required imports, knowing that in some scenarios the import will not be available and the linked export will silently also not be part of the catalog. We are using this to simulate a behavior where a MEF export in package A behaves as though it was provided by package B, where package A is always available but package B is optional. By implementing the export in package A with a required import from package B, the export becomes fully-conditioned on B.

Currently this scenario causes by-design errors in the composition. So hosts that rely on composition errors for diagnostics and investigation of real failures now get to either filter the by-design errors or manually filter the types that will get rejected in their composition.

I’m guessing one thing we can do is add

[Import(AllowRejection = true)]

or

[Import(RejectIfMissing = true)]

or

[Import(CausesRejectionIfMissing = true)]

and don’t report an error in the composition if the part is rejected.

See some discussion here: https://github.com/dotnet/roslyn/pull/42121

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
AArnottcommented, Mar 5, 2020

We’ll leave this active for now, but the extensibility team is booked through half of 16.7 already, so I don’t see this happening any time soon. If you’re willing to send the PR yourself, I can write a mini-spec for what I’d like to see and am willing to review it.

CC: @tinaschrepfer

1reaction
AArnottcommented, Mar 4, 2020

VS-MEF doesn’t define its own attributes, so we can’t do any of your suggestions.

I’m also concerned that folks might expect a behavioral change by setting something like AllowRejection=true when in fact rejection is always the behavior when a MEF part’s imports can’t be satisfied.

We could perhaps define a new attribute called [RejectionExpected] or something like that, that might be placed on the [Import] member or perhaps on the MEF part itself. I believe the only effect you want this to have is to designate it differently in the MEF composition log.

We would still need to record in the log that the part was rejected, since folks who want to know why it’s missing would still need to find the evidence, so all we’re talking about (I think) is adding an annotation to that log entry stating that rejection of this part might be expected.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can a rejection be appealed after reviewer says comments ...
Does a journal have the right to reject papers that they think are perfectly sound and publishable but not good enough for them?...
Read more >
Azure Repo PR Approval and Rejection - Microsoft Q&A
if there are 3 reviewers, 1 approval + 1 empty + 1 rejection should not allow to merge the PR with master. Is...
Read more >
A Nonmonotonic Modal Formalization of the Logic of ...
Uncertainty is understood as unability to decide to accept or reject a given fact. The language of the original AEL2 is that of...
Read more >
Your Accommodation Request Was Denied. What Now?
One strategy for doing this is to follow up with the employer by email to request a reason for the denial. It can...
Read more >
My paper is rejected from good conference. Do I have ...
It depends on the reason for rejection. If it was rejected for errors, methodological weaknesses, or poor presentation, then you will probably get...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found