You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After building your container, attach the Autofac.Diagnostics.DotGraph.DotDiagnosticTracer to the container. When every resolve operation completes (success or failure) you'll get a trace. It's up to you to determine what to do with that trace - write it to a file, render it to an image, etc.
// Build a container with some registrations.varcontainerBuilder=newContainerBuilder();containerBuilder.Register(ctx =>"Hello");varcontainer=containerBuilder.Build();// Attach a DotDiagnosticTracer to the container.// Handle the OperationCompleted event to deal// with the trace output.vartracer=newDotDiagnosticTracer();tracer.OperationCompleted+=(sender,args)=>{usingvarfile=File.OpenWrite(Guid.NewGuid().ToString()+".dot");usingvarwriter=newStreamWriter(file);writer.WriteLine(args.TraceContent);};container.SubscribeToDiagnostics(tracer);// Resolve some things and look at the graphs!// You can use graphviz to render a PNG like:// dot -T png -O filename.dotusingvarscope=container.BeginLifetimeScope();scope.Resolve<string>();
Tracing graphs is expensive! Getting a graph trace is convenient but does have a performance and memory/resource impact. It's recommended you only enable this in a development/troubleshooting situation.