{"id":37043602,"url":"https://github.com/jscarle/attributesourcegenerator","last_synced_at":"2026-01-14T05:00:57.197Z","repository":{"id":223947909,"uuid":"761989401","full_name":"jscarle/AttributeSourceGenerator","owner":"jscarle","description":"A simple attribute-based Roslyn incremental source generator base class for .NET.","archived":true,"fork":false,"pushed_at":"2024-03-06T18:00:45.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-13T23:20:15.768Z","etag":null,"topics":["attribute","attribute-based","charp","dotnet","source-generator","source-generators"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jscarle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"jscarle"}},"created_at":"2024-02-22T21:40:28.000Z","updated_at":"2024-03-22T22:21:41.000Z","dependencies_parsed_at":"2024-03-05T21:51:29.931Z","dependency_job_id":null,"html_url":"https://github.com/jscarle/AttributeSourceGenerator","commit_stats":null,"previous_names":["jscarle/attributesourcegenerator"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/jscarle/AttributeSourceGenerator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jscarle%2FAttributeSourceGenerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jscarle%2FAttributeSourceGenerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jscarle%2FAttributeSourceGenerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jscarle%2FAttributeSourceGenerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jscarle","download_url":"https://codeload.github.com/jscarle/AttributeSourceGenerator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jscarle%2FAttributeSourceGenerator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28410074,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["attribute","attribute-based","charp","dotnet","source-generator","source-generators"],"created_at":"2026-01-14T05:00:56.308Z","updated_at":"2026-01-14T05:00:57.163Z","avatar_url":"https://github.com/jscarle.png","language":"C#","readme":"# AttributeSourceGenerator\n\nA simple attribute-based Roslyn incremental source generator base class for .NET.\n\n[![main](https://img.shields.io/github/actions/workflow/status/jscarle/AttributeSourceGenerator/main.yml?logo=github)](https://github.com/jscarle/AttributeSourceGenerator)\n[![nuget](https://img.shields.io/nuget/v/AttributeSourceGenerator)](https://www.nuget.org/packages/AttributeSourceGenerator)\n[![downloads](https://img.shields.io/nuget/dt/AttributeSourceGenerator)](https://www.nuget.org/packages/AttributeSourceGenerator)\n\n### Example generator\n\n```csharp\nusing AttributeSourceGenerator;\nusing Microsoft.CodeAnalysis;\n\nnamespace SourceGenerators;\n\n[Generator]\npublic sealed class IdentifierSourceGenerator : AttributeIncrementalGeneratorBase\n{\n    public IdentifierSourceGenerator()\n        : base(() =\u003e new AttributeIncrementalGeneratorConfiguration()\n        {\n            MarkerAttributeName = MarkerAttributeName,\n            MarkerAttributeSource = MarkerAttributeSource,\n            SymbolFilter = FilterType.Struct,\n            SourceGenerator = GenerateIdentifier\n        })\n    {\n    }\n\n    private const string MarkerAttributeNamespace = \"Domain.Common.Attributes\";\n\n    private const string MarkerAttributeName = $\"{MarkerAttributeNamespace}.GeneratedIdentifierAttribute`1\";\n\n    private static source MarkerAttributeSource = new Source(\"GeneratedIdentifierAttribute`1\", $$\"\"\"\n        namespace {{MarkerAttributeNamespace}};\n        \n        [AttributeUsage(AttributeTargets.Struct)]\n        public sealed class GeneratedIdentifierAttribute\u003cTIdentifier\u003e : Attribute;                                                               \n        \"\"\";\n\n    private static IEnumerable\u003cSource\u003e GenerateIdentifier(Symbol symbol)\n    {\n        return [new Source(symbol.Name, $$\"\"\"\n            // \u003cauto-generated/\u003e\n            \n            #nullable enable\n            \n            namespace {{symbol.Namespace}};\n            \n            partial struct {{symbol.Name}} : IEquatable\u003c{{symbol.Name}}\u003e, IComparable\u003c{{symbol.Name}}\u003e, IComparable\n            {\n              // Implementation details\n            }\n            \"\"\")];\n    }\n}\n```\n\n### Typical .csproj\n\n```xml\n\u003cProject Sdk=\"Microsoft.NET.Sdk\"\u003e\n\n\t\u003cPropertyGroup\u003e\n\t\t\u003cTargetFramework\u003enetstandard2.0\u003c/TargetFramework\u003e\n\t\t\u003cNullable\u003eenable\u003c/Nullable\u003e\n\t\t\u003cImplicitUsings\u003etrue\u003c/ImplicitUsings\u003e\n\t\t\u003cLangVersion\u003elatest\u003c/LangVersion\u003e\n\t\t\u003cAnalysisLevel\u003elatest-All\u003c/AnalysisLevel\u003e\n\t\t\u003cEnforceExtendedAnalyzerRules\u003etrue\u003c/EnforceExtendedAnalyzerRules\u003e\n\t\t\u003cCodeAnalysisTreatWarningsAsErrors\u003etrue\u003c/CodeAnalysisTreatWarningsAsErrors\u003e\n\t\t\u003cTreatWarningsAsErrors\u003etrue\u003c/TreatWarningsAsErrors\u003e\n\t\u003c/PropertyGroup\u003e\n\n\t\u003cItemGroup\u003e\n\t\t\u003cPackageReference Include=\"Microsoft.CodeAnalysis.CSharp\" Version=\"4.3.1\" PrivateAssets=\"all\" /\u003e\n\t\t\u003cPackageReference Include=\"AttributeSourceGenerator\" Version=\"8.0.2\" PrivateAssets=\"all\" GeneratePathProperty=\"true\" /\u003e\n\t\u003c/ItemGroup\u003e\n\n\t\u003cPropertyGroup\u003e\n\t\t\u003cIsRoslynComponent\u003etrue\u003c/IsRoslynComponent\u003e\n\t\t\u003cIsPublishable\u003efalse\u003c/IsPublishable\u003e\n\t\t\u003cIsPackable\u003etrue\u003c/IsPackable\u003e\n\t\t\u003cIncludeBuildOutput\u003efalse\u003c/IncludeBuildOutput\u003e\n\t\t\u003cNoWarn\u003e$(NoWarn);NU5128\u003c/NoWarn\u003e\n\t\t\u003cGetTargetPathDependsOn\u003e$(GetTargetPathDependsOn);GetDependencyTargetPaths\u003c/GetTargetPathDependsOn\u003e\n\t\u003c/PropertyGroup\u003e\n\n\t\u003cItemGroup\u003e\n\t\t\u003cNone Include=\"$(PkgAttributeSourceGenerator)/lib/netstandard2.0/AttributeSourceGenerator.dll\" Pack=\"true\" PackagePath=\"analyzers/dotnet/cs\" Visible=\"false\" /\u003e\n\t\t\u003cNone Include=\"$(OutputPath)/$(AssemblyName).dll\" Pack=\"true\" PackagePath=\"analyzers/dotnet/cs\" Visible=\"false\" /\u003e\n\t\u003c/ItemGroup\u003e\n\n\t\u003cTarget Name=\"GetDependencyTargetPaths\"\u003e\n\t\t\u003cItemGroup\u003e\n\t\t\t\u003cTargetPathWithTargetPlatformMoniker Include=\"$(PkgAttributeSourceGenerator)/lib/netstandard2.0/AttributeSourceGenerator.dll\" IncludeRuntimeDependency=\"false\" /\u003e\n\t\t\t\u003cTargetPathWithTargetPlatformMoniker Include=\"$(MSBuildThisFileDirectory)bin/$(Configuration)/$(TargetFramework)/$(AssemblyName).dll\" IncludeRuntimeDependency=\"false\" /\u003e\n\t\t\u003c/ItemGroup\u003e\n\t\u003c/Target\u003e\n\n\u003c/Project\u003e\n```\n","funding_links":["https://github.com/sponsors/jscarle"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjscarle%2Fattributesourcegenerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjscarle%2Fattributesourcegenerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjscarle%2Fattributesourcegenerator/lists"}