A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/purview-dev/purview-telemetry-sourcegenerator/wiki/./Generation below:

Generation · kjldev/purview-telemetry-sourcegenerator Wiki · GitHub

The class name is generated from the parent interface with any initial I removed. I.e. ICacheServiceTelemetry would become CacheServiceTelemetry. Then Core is appended, so the final result would be a class named CacheServiceTelemetryCore.

The resulting class is also partial, internal and sealed. It is also generated within the owning namespace and any nested classes of the source interface.

Controlling the Generation

By applying the TelemetryGenerationAttribute from the Purview.Telemetry namespace you can control some aspects of generation.

This attribute is permitted on both the assembly and interface. Although take care when using the ClassName and DependencyInjectionClassName at the assembly level, as they will clash.

Name Type Description GenerateDependencyExtension bool Controls if the dependency injection class and extension method is generated. This defaults to true. ClassName string? Explicitly set the name of the class to be generated, rather than using the interface name. This defaults to null, meaning the interface name is used. DependencyInjectionClassName string? Similar to ClassName, but explicitly sets the name of the DI class name. DependencyInjectionClassIsPublic bool Setting this to true will generate the DI extension class as public, the default is false, which will make the class internal.

By default each interface source will have a generated dependency injection extension method, extending the IServiceCollection.

The generated method takes on the Add{InterfaceName} format, note that the interface name has any starting I removed. For example, given the ICacheServiceTelemetry interface, this would generate an extension method called AddCacheServiceTelemetry within the Microsoft.Extensions.DependencyInjection namespace.

When called, the source interface is added to the services collection as a singleton.

The generation can be disabled by setting TelemetryGenerationAttribute.GenerateDependencyExtension to false at the assembly level or on a per-interface basis.

You can exclude any method on an interface by applying the ExcludeAttribute, in the Purview.Telemetry namespace.

As the generated telemetry class is partial, you can implement any excluded methods you require in isolation.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4