WithServices(Action<ServiceBuilder>)
Configures additional services for this collection, resetting any previously registered services, and returns the current collection.
Declaration
public WorkspaceCollection WithServices(Action<ServiceBuilder> configure)Parameters
| Type | Name | Description |
|---|---|---|
| Action<ServiceBuilder> | configure | An action that configures services on the ServiceBuilder. |
Returns
| Type | Description |
|---|---|
| WorkspaceCollection | The current WorkspaceCollection instance for method chaining. |
Remarks
Important: This method must be called before any call to Load(params string[]) or LoadAsync(params string[]). Services configured after loading have no effect on already-loaded workspaces.
This method first clears any previously registered services, then invokes the configure action to register new services. Services are available for metric computations and other extensibility points.
Example usage with metrics:
WorkspaceCollection.Default
.WithServices(s => s.AddMetrics())
.Load("MySolution.sln")
.SourceCode
.Methods
.Select(m => m.Metrics().Get<SyntaxNodesCount>())