Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/juniorporfirio/grpcinjection
A Source Generator to C#, that allow you injection Grpc Services and Interceptors without Reflection :)
https://github.com/juniorporfirio/grpcinjection
build csharp csharp-sourcegenerator dotnet dotnet-core source-generator source-generators sourcegenerator
Last synced: 3 months ago
JSON representation
A Source Generator to C#, that allow you injection Grpc Services and Interceptors without Reflection :)
- Host: GitHub
- URL: https://github.com/juniorporfirio/grpcinjection
- Owner: juniorporfirio
- License: mit
- Created: 2022-03-09T14:05:18.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-03-09T14:54:59.000Z (over 2 years ago)
- Last Synced: 2024-07-05T00:27:36.692Z (4 months ago)
- Topics: build, csharp, csharp-sourcegenerator, dotnet, dotnet-core, source-generator, source-generators, sourcegenerator
- Language: C#
- Homepage:
- Size: 17.6 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- RSCG_Examples - GrpcInjection
- csharp-source-generators - GrpcInjection - ![stars](https://img.shields.io/github/stars/juniorporfirio/grpcinjection?style=flat-square&cacheSeconds=604800) ![last commit](https://img.shields.io/github/last-commit/juniorporfirio/grpcinjection?style=flat-square&cacheSeconds=86400) - GrpcInjection is a tool that allow you to inject Services and Interceptor in time of compilation inside of GRPC Projects using C# source generator. (Source Generators / Dependency Injection (IoC Container))
README
# Grpc Injection
A Source Generator package for C#, that allow you to generate Grpc Services and Interceptors dependencies without Reflection.[![Build](https://github.com/juniorporfirio/grpcinjection/actions/workflows/dotnet.yml/badge.svg)](https://github.com/juniorporfirio/grpcinjection/actions/workflows/dotnet.yml) [![License](https://img.shields.io/github/license/juniorporfirio/grpcinjection.svg)](https://github.com/juniorporfirio/grpcinjection/blob/master/LICENSE)
## Installing
The package is available ([on NuGet](https://www.nuget.org/packages/grpcinjection).
To install from the command line:```shell
dotnet add package GrpcInjection
```Or use the Package Manager in Visual Studio.
## Setup Service Provider
Only add in your Startup or Program for use this package, like so:
```csharp
public void ConfigureServices(IServiceCollection services)
{
services.AddGrpcInject();
}public void Configure(IApplicationBuilder app)
{
app.UseGrpcInject();
}
```## Inject one Service Grpc
Only add an attribute to the classes Grpc Service that you want injected in your service provider, like so:```csharp
[GrpcService]
public class GreeterService : Greeter.GreeterBase
{
private readonly ILogger _logger;
public GreeterService(ILogger logger)
{
_logger = logger;
}public override Task SayHello(HelloRequest request, ServerCallContext context)
{
return Task.FromResult(new HelloReply
{
Message = "Hello " + request.Name
});
}
}
```## Inject one Interceptor Grpc
Only add an attribute to the classes Grpc Interceptors that you want injected in your service provider, like so:```csharp
[GrpcInterceptor]
public class LogInterceptor : Interceptor
{
private readonly ILogger _logger;
public LogInterceptor(ILogger logger) => _logger = logger;}
```
## ContributingThe main supported IDE for development is Visual Studio 2022.
Questions, comments, bug reports, and pull requests are all welcome.
Bug reports that include steps to reproduce (including code) are
preferred. Even better, make them in the form of pull requests.
Before you start to work on an existing issue, check if it is not assigned
to anyone yet, and if it is, talk to that person.## Maintainers/Core team
- [Júnior Porfirio](http://juniorporfirio.medium.com/), aka JP,
[@juniorporfirio](https://twitter.com/juniorporfirio)Contributors can be found at the [contributors](https://github.com/juniorporfirio/grpcinjection/graphs/contributors) page on Github.
## License
This software is open source, licensed under the MIT License.
See [LICENSE](https://github.com/juniorporfirio/grpcinjection/blob/master/LICENSE) for details.
Check out the terms of the license before you contribute, fork, copy or do anything
with the code. If you decide to contribute you agree to grant copyright of all your contribution to this project and agree to
mention clearly if do not agree to these terms. Your work will be licensed with the project at MIT, along the rest of the code.