https://github.com/ufcpp/internalreservedattributegenerator
A C# Source Generator for generating C# reserved attributes with internal accessibility.
https://github.com/ufcpp/internalreservedattributegenerator
csharp-sourcegenerator
Last synced: 10 months ago
JSON representation
A C# Source Generator for generating C# reserved attributes with internal accessibility.
- Host: GitHub
- URL: https://github.com/ufcpp/internalreservedattributegenerator
- Owner: ufcpp
- License: mit
- Created: 2021-06-29T03:12:21.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-22T09:05:47.000Z (over 3 years ago)
- Last Synced: 2025-02-01T23:17:49.121Z (12 months ago)
- Topics: csharp-sourcegenerator
- Language: C#
- Homepage:
- Size: 18.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# InternalReservedAttributeGenerator
A C# Source Generator for generating C# reserved attributes with internal accessibility.
see also: https://github.com/ufcpp/InternalReservedAttributeContent
Some C# features depend on attributes and modifiers but these can be internal. For instance, you may get [CS0518](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs0518?f1url=%3FappId%3Droslyn%26k%3Dk(CS0518)) "Predefined type 'System.Runtime.CompilerServices.IsExternalInit' is not defined or imported" errors when using records (C# 9.0 feature) and you can avoid this error by adding the `IsExternalInit` class internally in your project.
```cs
namespace System.Runtime.CompilerServices
{
internal sealed class IsExternalInit { }
}
```
The InternalReservedAttributeGenerator automatically generates these attributes and modifiers:
- IsExternalInit for [init-only properties](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-9.0/init.md) / [records](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-9.0/records.md)
- ModuleInitializerAttribute for [module initializers](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-9.0/module-initializers.md)
- SkipLocalsInitAttribute for [localsinit flag](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-9.0/skip-localsinit.md)
- Attributes for [null-state static analysis](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/attributes/nullable-analysis)
## NuGet
[](https://www.nuget.org/packages/InternalReservedAttributeGenerator)