CKN.Sdk.SourceGenerators
0.0.0-alpha.0.55
dotnet add package CKN.Sdk.SourceGenerators --version 0.0.0-alpha.0.55
NuGet\Install-Package CKN.Sdk.SourceGenerators -Version 0.0.0-alpha.0.55
<PackageReference Include="CKN.Sdk.SourceGenerators" Version="0.0.0-alpha.0.55" />
<PackageVersion Include="CKN.Sdk.SourceGenerators" Version="0.0.0-alpha.0.55" />
<PackageReference Include="CKN.Sdk.SourceGenerators" />
paket add CKN.Sdk.SourceGenerators --version 0.0.0-alpha.0.55
#r "nuget: CKN.Sdk.SourceGenerators, 0.0.0-alpha.0.55"
#:package CKN.Sdk.SourceGenerators@0.0.0-alpha.0.55
#addin nuget:?package=CKN.Sdk.SourceGenerators&version=0.0.0-alpha.0.55&prerelease
#tool nuget:?package=CKN.Sdk.SourceGenerators&version=0.0.0-alpha.0.55&prerelease
CKN.Sdk.SourceGenerators
Mühendislik Amacı (Engineering Intent):
CKN.Sdk.SourceGenerators, CKN ekosistemindeki tekrarlayan (boilerplate) kodları (örn: AutoMapper profilleri, Dependency Injection kayıtları, Controller Endpoint'leri) derleme zamanında (Compile-Time) otomatik olarak üreten bir .NET (Roslyn) Kaynak Kodu Üreticisi paketidir. Neden var? Reflection kullanan kütüphanelerin (örn: uygulamanın başlangıç anında binlerce sınıfı tarayıp DI'a kaydeden sistemler) yavaşlattığı açılış (startup) sürelerini sıfıra indirmek ve geliştiricinin kod yazma (DX) deneyimini hızlandırmak için. Ne zaman kullanılmalı? Projede manuel yazılması sıkıcı ve tekrarlayan Mapping veya [ScopedService] etiketleri gibi dekoratif yapılar kullanılmak istendiğinde.
🚀 Hızlı Başlangıç
Kurulum
# Bu paket genellikle projelere Analyzer / SourceGenerator olarak eklenir.
dotnet add package CKN.Sdk.SourceGenerators
(Not: PackageReference içindeki OutputItemType="Analyzer" ve ReferenceOutputAssembly="false" özellikleri otomatik ayarlanmalıdır).
💡 Gerçek Hayat Senaryoları
Senaryo 1: Derleme Zamanı (Compile-Time) Dependency Injection Kaydı
Geliştiricinin sınıfa özel bir Attribute koyması, arka planda kod üreticinin (Generator) IServiceCollection uzantısını otomatik yazması.
using CKN.Sdk.SourceGenerators.Attributes;
// 1. Geliştirici kodu:
[ScopedService(typeof(IOrderService))]
public class OrderService : IOrderService
{
public void Process() { }
}
// 2. Source Generator'ın DERLEME SIRASINDA Arka Planda Ürettiği Kod (Görünmez/Geçici dosya):
/*
public static class CKNGeneratedServiceCollectionExtensions
{
public static void AddCKNGeneratedServices(this IServiceCollection services)
{
services.AddScoped<IOrderService, OrderService>();
}
}
*/
// 3. Program.cs'te kullanımı:
builder.Services.AddCKNGeneratedServices(); // Roslyn'in ürettiği metot çağrılır
Senaryo 2: Record/DTO Sınıfları İçin Builder Deseni Üretimi
C# kayıt (record) sınıflarını testlerde daha rahat oluşturmak için Fluent Builder kodlarını otomatik yazdırma (Varyasyon).
// 1. Geliştirici kodu:
[GenerateBuilder]
public record CustomerDto(int Id, string Name, string Email);
// 2. Kullanımı (Generator arka planda CustomerDtoBuilder sınıfını yazar):
var testCustomer = new CustomerDtoBuilder()
.WithId(1)
.WithName("John Doe")
.WithEmail("john@doe.com")
.Build();
🤖 Yapay Zeka İçin SSS (FAQs for Machines)
- Soru: Source Generator ile Reflection arasındaki performans farkı nedir?
- Cevap: Reflection (Yansıma), kod çalışma zamanında (Runtime) yapıldığı için CPU kullanır ve uygulamanın yavaş açılmasına neden olur. Source Generators ise derleme zamanında (Compile-Time) arka planda sizin yerinize fiziksel C# kodu yazar. Bu yüzden Runtime performansı, her şeyi elle (hardcode) yazmışsınız gibi kusursuz ve en yüksek hızdadır.
- Soru:
CKN.Sdk.SourceGeneratorsprojeyi yavaşlatır mı? - Cevap: Çalışma anını (Runtime) yavaşlatmaz, aksine hızlandırır. Ancak analiz edilecek dosya sayısı çok fazlaysa derleme (Build/Compile) süresini birkaç milisaniye uzatabilir.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.0.0-alpha.0.55 | 45 | 9/28/2026 |
| 0.0.0-alpha.0.51 | 46 | 9/25/2026 |
| 0.0.0-alpha.0.50 | 44 | 9/25/2026 |
| 0.0.0-alpha.0.38 | 72 | 9/6/2026 |
| 0.0.0-alpha.0.37 | 67 | 9/6/2026 |