{"id":13629566,"url":"https://github.com/betwixt-labs/dot-env-generator","last_synced_at":"2025-04-17T09:34:45.160Z","repository":{"id":43001471,"uuid":"425704168","full_name":"betwixt-labs/dot-env-generator","owner":"betwixt-labs","description":"A source generator for C# that turns .env files into runtime constants. ","archived":false,"fork":false,"pushed_at":"2022-11-05T23:33:44.000Z","size":39,"stargazers_count":32,"open_issues_count":2,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-02T17:03:47.951Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/betwixt-labs.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}},"created_at":"2021-11-08T05:02:16.000Z","updated_at":"2024-03-09T18:54:48.000Z","dependencies_parsed_at":"2022-08-23T14:40:58.970Z","dependency_job_id":null,"html_url":"https://github.com/betwixt-labs/dot-env-generator","commit_stats":null,"previous_names":["betwixt-labs/dot-env-generator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betwixt-labs%2Fdot-env-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betwixt-labs%2Fdot-env-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betwixt-labs%2Fdot-env-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betwixt-labs%2Fdot-env-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/betwixt-labs","download_url":"https://codeload.github.com/betwixt-labs/dot-env-generator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223751234,"owners_count":17196591,"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":[],"created_at":"2024-08-01T22:01:13.727Z","updated_at":"2024-11-08T20:31:13.811Z","avatar_url":"https://github.com/betwixt-labs.png","language":"C#","funding_links":[],"categories":["Do not want to test 112 ( old ISourceGenerator )"],"sub_categories":["1. [ThisAssembly](https://ignatandrei.github.io/RSCG_Examples/v2/docs/ThisAssembly) , in the [EnhancementProject](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enhancementproject) category"],"readme":"# dot-env-generator\nA source generator for C# that turns .env files into runtime constants. \n\n## Basic Usage\n\n\n| NuGet            |       | [![DotEnvGenerator][1]][2]                                       |\n| :--------------- | ----: | :--------------------------------------------------------------- |\n| Package Manager  | `PM\u003e` | `Install-Package DotEnvGenerator -Version 0.1.0`                 |\n| .NET CLI         | `\u003e`   | `dotnet add package DotEnvGenerator --version 0.1.0`             |\n| PackageReference |       | `\u003cPackageReference Include=\"DotEnvGenerator\" Version=\"0.1.0\" /\u003e` |\n| Paket CLI        | `\u003e`   | `paket add DotEnvGenerator --version 0.1.0`                      |\n\n[1]: https://img.shields.io/nuget/v/DotEnvGenerator.svg?label=DotEnvGenerator\n[2]: https://www.nuget.org/packages/DotEnvGenerator\n\nAfter adding the source generator to your project add an item group to your project that references your .env file like so:\n\n```xml\n  \u003cItemGroup\u003e\n    \u003cAdditionalFiles Include=\"example.env\" /\u003e\n  \u003c/ItemGroup\u003e\n```\n\nThe contents of your .env file would look something like this:\n```env\n# A string literal\nA_STRING=\"yep, that is a string.\"\n# A string\nALSO_STRING=RANDOM_0026256698\n# An array of string\nSTRING_ARRAY=one,two,three,four,five\n# An array of numbers\nINT_ARRAY=1, 2, 3, 4, 5, 6, 7\nA_NUMBER=1000\nA_BIGGER_NUMBER=10_000_000\nA_GUID=de095b54-2082-40f8-a928-794da5675e7c\nA_DATE_TIME=Tue, 1 Jan 2008 00:00:00Z\n# A base64 encoded bytearray \nA_BYTE_ARRAY=d2hhdA==\nA_DOUBLE=1.0\nA_SCIENCE_DOUBLE=3.2e23\nA_DOUBLE_LITERAL=1.0D\nA_HEX=0xFF0000\nA_UINT=2000U\nA_LONG=2000L\nA_ULONG=2000UL\nA_NEGATIVE_LONG=-2000L\n```\n\nAnd the generator will turn it into this:\n\n```csharp\nusing System;\nnamespace DotEnv.Generated\n{\n    /// \u003csummary\u003e\n    /// An auto-generated class which holds constants derived from 'example.env'\n    /// \u003c/summary\u003e\n    public static class ExampleEnvironment\n    {\n       /// \u003csummary\u003e A string literal \u003c/summary\u003e\n       public const System.String AString = \"yep, that is a string.\";\n       /// \u003csummary\u003e A string \u003c/summary\u003e\n       public const System.String AlsoString = \"RANDOM_0026256698\";\n       /// \u003csummary\u003e An array of string \u003c/summary\u003e\n       public static readonly IReadOnlyList\u003cSystem.String\u003e StringArray = new string[] { \"one\", \"two\", \"three\", \"four\", \"five\" };\n       /// \u003csummary\u003e An array of numbers \u003c/summary\u003e\n       public static readonly IReadOnlyList\u003cSystem.Int32\u003e IntArray = new System.Int32[] { 1, 2, 3, 4, 5, 6, 7 };\n       public const System.Int32 ANumber = 1000;\n       public const System.Int32 ABiggerNumber = 10_000_000;\n       public static readonly System.Guid AGuid = Guid.Parse(\"de095b54-2082-40f8-a928-794da5675e7c\");\n       public static readonly System.DateTime ADateTime = DateTime.Parse(\"Tue, 1 Jan 2008 00:00:00Z\");\n       /// \u003csummary\u003e A base64 encoded bytearray \u003c/summary\u003e\n       public static ReadOnlySpan\u003cbyte\u003e AByteArray =\u003e new byte[] { 0x77, 0x68, 0x61, 0x74 };\n       public const System.Double ADouble = 1.0;\n       public const System.Double AScienceDouble = 3.2e23;\n       public const System.Double ADoubleLiteral = 1.0D;\n       public const System.Int32 AHex = 0xFF0000;\n       public const System.UInt32 AUint = 2000U;\n       public const System.Int64 ALong = 2000L;\n       public const System.UInt64 AUlong = 2000UL;\n       public const System.Int64 ANegativeLong = -2000L;\n    }\n}\n```\n\nThe source generator will use your .env file first as a lookup table. Using the left-hand declarations the generator will check for an environment variable with that name in descending order (machine, user, and finally the process.) \n\nIf the variable does not exist in any of these stores, the value on the right is used. If no default value is defined, an error is reported.\n\n\nThe value parsing rules are simple:\n- Anything wrapped in double quotes is treated as a string.\n- If an array has multiple types the entire array is treated as an array of strings.\n- Any value that cannot have its CLR type determined is treated as a string.\n- Base64 strings are always considered to be byte arrays. \n\n## Known Issues \n- Some strings may be detected as being Base64 even if they aren't. If you encounter this issue just wrap you string in double quotes.\n- No tokenzation or lexing is performed on the .env file, and as such there is no validation of the .env file or its values. The parsing is very rudimentary.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbetwixt-labs%2Fdot-env-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbetwixt-labs%2Fdot-env-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbetwixt-labs%2Fdot-env-generator/lists"}