{"id":16316872,"url":"https://github.com/llukas22/propertyinterception","last_synced_at":"2025-05-13T15:38:37.545Z","repository":{"id":106854043,"uuid":"420392487","full_name":"LLukas22/PropertyInterception","owner":"LLukas22","description":"Cauldron like Property-Iterception using C# Source Generators","archived":false,"fork":false,"pushed_at":"2022-02-14T15:40:39.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-16T19:48:40.449Z","etag":null,"topics":["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/LLukas22.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null}},"created_at":"2021-10-23T11:23:46.000Z","updated_at":"2024-05-13T17:18:35.000Z","dependencies_parsed_at":"2023-04-10T18:01:04.619Z","dependency_job_id":null,"html_url":"https://github.com/LLukas22/PropertyInterception","commit_stats":{"total_commits":6,"total_committers":1,"mean_commits":6.0,"dds":0.0,"last_synced_commit":"a4afa644b37a5d53bebaba8f1679d7dbfdca4147"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LLukas22%2FPropertyInterception","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LLukas22%2FPropertyInterception/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LLukas22%2FPropertyInterception/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LLukas22%2FPropertyInterception/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LLukas22","download_url":"https://codeload.github.com/LLukas22/PropertyInterception/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253971197,"owners_count":21992667,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["source-generators"],"created_at":"2024-10-10T22:05:52.218Z","updated_at":"2025-05-13T15:38:37.503Z","avatar_url":"https://github.com/LLukas22.png","language":"C#","readme":"# PropertyInterception [![NuGet](https://img.shields.io/nuget/v/PropertyInterception.svg)](https://www.nuget.org/packages/PropertyInterception/)\n\nCauldron like [Property-Interception](https://github.com/Capgemini/Cauldron/wiki/Property-interception) using C# Source Generators.\nThis Package allows you to control the Getter- and Setter-Behaviour of your Properties via an Attribute. \n\n## Installation\n---\nVia Nuget: \u003ccode\u003eInstall-Package PropertyInterception\u003c/code\u003e \n\u003cbr\u003e\nOr download a [Release](https://github.com/LLukas22/PropertyInterception/releases).\n\n## How it works\n---\nYour code:\n```C#\ninternal class InterceptionAttribute : Attribute, IPropertyGetterInterceptor, IPropertySetterInterceptor\n{\n    public bool OnException(PropertyInterceptionInfo propertyInterceptionInfo, Exception exception)\n    {\n        //Do Something on Error\n        return false;\n    }\n\n    public void OnExit(PropertyInterceptionInfo propertyInterceptionInfo)\n    {\n        //Do Something on Exit\n    }\n\n    public void OnGet(PropertyInterceptionInfo propertyInterceptionInfo, object currentValue)\n    {\n        //Do Something on Get\n    }\n\n    public bool OnSet(PropertyInterceptionInfo propertyInterceptionInfo, object oldValue, object newValue)\n    {\n        //Do Something on Set\n        return true;\n    }\n}\n```\n```C#\npublic partial class Person\n{\n    [Interception]\n    private string name;\n}\n```\n\nWhat gets generated:\n\n```C#\npublic partial class Person\n{\n    [NonSerialized]\n    private NugetTest.InterceptionAttribute name_propertyInterceptionAttribute;\n    [NonSerialized]\n    private PropertyInterceptionInfo name_propertyInterceptionInfo;\n\n        \n    public string Name \n    {\n        get\n        {\n            \n            if(this.name_propertyInterceptionInfo == null)\n            {\n                this.name_propertyInterceptionInfo = new PropertyInterceptionInfo(this,\"name\");\n            }\n\n            if(this.name_propertyInterceptionAttribute == null)\n            {\n                this.name_propertyInterceptionAttribute = new NugetTest.InterceptionAttribute();\n            }\n\n            try\n            {\n                name_propertyInterceptionAttribute.OnGet(this.name_propertyInterceptionInfo, this.name);\n                return this.name;\n            }\n            catch (Exception e)\n            {\n                if(name_propertyInterceptionAttribute.OnException(this.name_propertyInterceptionInfo,e))\n                    throw;\n                else\n                    return this.name;\n            }\n            finally\n            {\n                name_propertyInterceptionAttribute.OnExit(this.name_propertyInterceptionInfo);\n            }\n    \n        }\n\n        set\n        {\n            \n            if(this.name_propertyInterceptionInfo == null)\n            {\n                this.name_propertyInterceptionInfo = new PropertyInterceptionInfo(this,\"name\");\n            }\n\n            if(this.name_propertyInterceptionAttribute == null)\n            {\n                this.name_propertyInterceptionAttribute = new NugetTest.InterceptionAttribute();\n            }\n\n            try\n            {\n                if(name_propertyInterceptionAttribute.OnSet(this.name_propertyInterceptionInfo, this.name, value))\n                {\n                    this.name = value;\n                }\n            }\n            catch (Exception e)\n            {\n                if(name_propertyInterceptionAttribute.OnException(this.name_propertyInterceptionInfo,e))\n                    throw;\n            }\n            finally\n            {\n                name_propertyInterceptionAttribute.OnExit(this.name_propertyInterceptionInfo);\n            }\n    \n        }      \n    }\n\n}\n```\n\nSee PropertyInterception.Tests for more examples.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllukas22%2Fpropertyinterception","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fllukas22%2Fpropertyinterception","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllukas22%2Fpropertyinterception/lists"}