Skip to content

Document Service Fabric interception, scoping, and package versioning - #188

Merged
tillig merged 1 commit into
mainfrom
feature/servicefabric-doc-updates
Aug 14, 2026
Merged

Document Service Fabric interception, scoping, and package versioning#188
tillig merged 1 commit into
mainfrom
feature/servicefabric-doc-updates

Conversation

@tillig

@tillig tillig commented Aug 14, 2026

Copy link
Copy Markdown
Member

Fixes #187.

Three long-standing issues on the Autofac.ServiceFabric repo turned out to be documentation gaps rather than code defects. They're being closed in favor of #187, and this covers them.

What's added

Registration Requirements — the page never mentioned that every registered service and actor type is wrapped in a dynamic proxy, or what that requires (class, not sealed/abstract, only virtual members intercepted). Those constraints only existed in API XML docs.

Internal Service Typesresolves Autofac.ServiceFabric#49. An internal service type needs InternalsVisibleTo for DynamicProxyGenAssembly2, and which form depends on whether the consumer's own assembly is strong named, because Castle only signs its generated assembly when the assembly holding the proxied type is signed. Using the keyed Castle.Core.Internal constant from an unsigned assembly is what produces Access is denied — a genuinely misleading error for the actual cause. Added a note saying so explicitly, since people reasonably assume it's about whether Autofac.ServiceFabric is signed.

Service and Actor Lifetime Scopesresolves Autofac.ServiceFabric#51. Documents that the SF context objects are registered into the per-replica child scope, not the root container, and therefore that a component depending on ServiceContext can't be SingleInstance(). Shows the failing registration next to the InstancePerMatchingLifetimeScope("ServiceFabric") fix. Also notes that Lazy<T>/Func<T> don't help, since that's what the reporter tried first.

Adding Registrations to the Service Scope — documents the configurationAction parameter of RegisterServiceFabricSupport, which shipped in v4.0.0 and was never documented. Uses the Application Insights FabricTelemetryInitializer example from Autofac.ServiceFabric#57, which is the scenario it was built for.

Service Fabric Package Versionsresolves Autofac.ServiceFabric#18, open since 2017. The Microsoft.ServiceFabric.* packages pin each other to exact versions, so the version Autofac.ServiceFabric depends on effectively sets the SF package version for the whole consuming project. Mixing versions yields NU1608. Documented as guidance because it's inherent to Microsoft's versioning and the integration can't work around it.

What's removed

The Example section. It linked to autofac/Examples/tree/master/src/ServiceFabricDemo, and that directory was deleted from the Examples repo — on a branch that has since been renamed from master to main, so the link was dead twice over. Rather than leave a broken link or replace it with meta-commentary about missing content, the section is gone; it should be restored when a current sample lands (tracked separately in the Examples repo).

Deliberately not included

The constructorExceptionCallback signature change from Autofac.ServiceFabric#47 is unreleased, so documenting it now would describe API that isn't on NuGet yet. That belongs with the next release.

Verification

doc8 clean, and a full sphinx -b html build succeeds with every new section rendering correctly. The only build warnings are two pre-existing unknown document: '../troubleshooting/diagnostics' references in faq/container-analysis.rst and lifetime/disposal.rst, unrelated to this change.

Several long-standing issues on the Autofac.ServiceFabric repo were
documentation gaps rather than code defects. Cover them here:

- Registration requirements for the dynamic proxy, including which form of
  InternalsVisibleTo an internal service type needs. The keyed Castle
  constant only works from a strong-named assembly, and using it from an
  unsigned one is the usual cause of "Access is denied".
- Where the Service Fabric context objects are registered, and why a
  component depending on ServiceContext cannot be SingleInstance.
- The configurationAction hook, which is the only place a component that
  needs ServiceContext at construction can be registered.
- That the Microsoft.ServiceFabric.* packages pin each other exactly, so
  consumers need to align their SF package versions.

Also drops the Example section. It linked to a sample that no longer
exists in the Examples repository, on a branch that has been renamed.

Fixes #187.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant