Skip to content

Commit 4ea1599

Browse files
Merge pull request #68 from bolorundurowb/ft/#66/update-method-documentation
ft #66: update method documentation
2 parents 5eb1d26 + 03bcd98 commit 4ea1599

10 files changed

Lines changed: 186 additions & 170 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build, Test & Coverage
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-and-test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Setup .NET 10 SDK
16+
uses: actions/setup-dotnet@v4
17+
with:
18+
dotnet-version: '10.x'
19+
20+
- name: Restore dependencies
21+
run: dotnet restore
22+
working-directory: ./src
23+
24+
- name: Build all projects
25+
run: dotnet build --configuration Release --no-restore
26+
working-directory: ./src
27+
28+
- name: Run tests with code coverage
29+
run: dotnet test --configuration Release --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=../../coverage/coverage.cobertura.xml
30+
working-directory: ./src
31+
32+
- name: Upload coverage to Codecov
33+
uses: codecov/codecov-action@v5
34+
with:
35+
token: ${{ secrets.CODECOV_TOKEN }}
36+
directory: ./coverage/
37+
fail_ci_if_error: true

.github/workflows/build.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

README.md

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![CI - Build, Test & Coverage](https://github.com/bolorundurowb/dotenv.net/actions/workflows/build.yml/badge.svg)](https://github.com/bolorundurowb/dotenv.net/actions/workflows/build.yml)
44
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
5-
[![Coverage Status](https://coveralls.io/repos/github/bolorundurowb/dotenv.net/badge.svg?branch=master)](https://coveralls.io/github/bolorundurowb/dotenv.net?branch=master)
5+
[![codecov](https://codecov.io/gh/bolorundurowb/dotenv.net/graph/badge.svg?token=Qw8xSiEHNp)](https://codecov.io/gh/bolorundurowb/dotenv.net)
66
![NuGet Version](https://img.shields.io/nuget/v/dotenv.net)
77

88

@@ -19,7 +19,7 @@ Whether you're building a small project or a large-scale application, **dotenv.n
1919
- **Simple and Pain-Free** 🎯: Easily load and read `.env` files with minimal setup.
2020
- **Flexible Configuration** 🔧: Customize how environment variables are loaded with a variety of options.
2121
- **Dependency Injection Support** 🧩: Works seamlessly with popular DI frameworks.
22-
- **Cross-Platform** 🌍: Fully compatible with .NET Core, .NET 5, and beyond.
22+
- **Cross-Platform** 🌍: Fully compatible with .NET Core, .NET 5, .NET 6, .NET 9 and beyond.
2323
- **Open Source** 💡: Actively maintained and supported by the community.
2424

2525
---
@@ -42,7 +42,7 @@ You can install **dotenv.net** via NuGet:
4242

4343
- **Manual Installation** (via `.csproj`):
4444
```xml
45-
<PackageReference Include="dotenv.net" Version="4.0.0"/>
45+
<PackageReference Include="dotenv.net" Version="4.x.x"/>
4646
```
4747

4848
---
@@ -61,13 +61,43 @@ You can install **dotenv.net** via NuGet:
6161
DotEnv.Load();
6262
```
6363

64-
This will automatically locate and load the `.env` file in the same directory as your application.
64+
This will automatically locate and load the `.env` file in the same directory as your application's executable.
65+
66+
---
67+
68+
### Fluent API 🎨
69+
70+
For a more expressive syntax, **dotenv.net** provides a fluent API:
71+
72+
```csharp
73+
// Load environment variables with custom options
74+
DotEnv.Fluent()
75+
.WithExceptions()
76+
.WithEnvFiles("./path/to/env")
77+
.WithTrimValues()
78+
.WithEncoding(Encoding.ASCII)
79+
.WithOverwriteExistingVars()
80+
.WithProbeForEnv(probeLevelsToSearch: 6)
81+
.WithSupportExportSyntax()
82+
.Load();
83+
84+
// Read environment variables
85+
var envVars = DotEnv.Fluent()
86+
.WithoutExceptions()
87+
.WithEnvFiles() // Defaults to .env
88+
.WithoutTrimValues()
89+
.WithEncoding(Encoding.UTF8)
90+
.WithoutOverwriteExistingVars()
91+
.WithoutProbeForEnv()
92+
.WithoutSupportExportSyntax()
93+
.Read();
94+
```
6595

6696
---
6797

6898
### Advanced Configuration ⚙️
6999

70-
**dotenv.net** offers a wide range of configuration options to tailor the loading process to your needs:
100+
**dotenv.net** offers a wide range of configuration options to tailor the loading process to your needs using the `DotEnvOptions` class:
71101

72102
- **Specify Custom `.env` File Paths**:
73103
```csharp
@@ -112,36 +142,6 @@ Console.WriteLine(envVars["KEY"]); // Outputs the value associated with 'KEY'
112142

113143
---
114144

115-
### Fluent API 🎨
116-
117-
For a more expressive syntax, **dotenv.net** provides a fluent API:
118-
119-
```csharp
120-
// Load environment variables with custom options
121-
DotEnv.Fluent()
122-
.WithExceptions()
123-
.WithEnvFiles("./path/to/env")
124-
.WithTrimValues()
125-
.WithEncoding(Encoding.ASCII)
126-
.WithOverwriteExistingVars()
127-
.WithProbeForEnv(probeLevelsToSearch: 6)
128-
.WithSupportExportSyntax()
129-
.Load();
130-
131-
// Read environment variables
132-
var envVars = DotEnv.Fluent()
133-
.WithoutExceptions()
134-
.WithEnvFiles() // Defaults to .env
135-
.WithoutTrimValues()
136-
.WithDefaultEncoding()
137-
.WithoutOverwriteExistingVars()
138-
.WithoutProbeForEnv()
139-
.WithoutSupportExportSyntax()
140-
.Read();
141-
```
142-
143-
---
144-
145145
### Environment Variable Helpers 🛠️
146146

147147
The `Utilities` namespace provides additional methods for reading environment variables in a typed manner:

src/dotenv.net.Tests/ReaderTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,6 @@ public void GetProbedEnvPath_FileNotFoundAndIgnoreExceptionsFalse_ShouldThrow()
201201
exception.Message.ShouldContain($"after searching {levelsToSearch} directory level(s) upwards.");
202202
exception.Message.ShouldContain("Searched paths:");
203203
exception.Message.ShouldContain(_startPath);
204-
exception.Message.ShouldContain("net9.0");
205-
exception.Message.ShouldContain("Debug");
206204
}
207205

208206
[Fact]

src/dotenv.net.Tests/dotenv.net.Tests.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net9.0</TargetFramework>
3+
<TargetFramework>net10.0</TargetFramework>
44
<IsPackable>false</IsPackable>
55
<LangVersion>latest</LangVersion>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>
88
<ItemGroup>
9-
<PackageReference Include="coverlet.collector" Version="6.0.4">
9+
<PackageReference Include="coverlet.collector" Version="8.0.0">
1010
<PrivateAssets>all</PrivateAssets>
1111
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1212
</PackageReference>
13-
<PackageReference Include="coverlet.msbuild" Version="6.0.4">
13+
<PackageReference Include="coverlet.msbuild" Version="8.0.0">
1414
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
1515
<PrivateAssets>all</PrivateAssets>
1616
</PackageReference>
17-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1"/>
17+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
1818
<PackageReference Include="Shouldly" Version="4.3.0" />
1919
<PackageReference Include="xunit" Version="2.9.3"/>
20-
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.1">
20+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
2121
<PrivateAssets>all</PrivateAssets>
2222
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2323
</PackageReference>

dotenv.net.sln renamed to src/dotenv.net.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# Visual Studio 2013
33
VisualStudioVersion = 12.0.0.0
44
MinimumVisualStudioVersion = 10.0.0.1
5-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotenv.net", "src\dotenv.net\dotenv.net.csproj", "{ABC30C21-62C1-4DF5-B352-4D33BCDD9845}"
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotenv.net", "dotenv.net\dotenv.net.csproj", "{ABC30C21-62C1-4DF5-B352-4D33BCDD9845}"
66
EndProject
7-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotenv.net.Tests", "src\dotenv.net.Tests\dotenv.net.Tests.csproj", "{FC5ED4B3-DFDC-45E9-889C-847433F08E0E}"
7+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotenv.net.Tests", "dotenv.net.Tests\dotenv.net.Tests.csproj", "{FC5ED4B3-DFDC-45E9-889C-847433F08E0E}"
88
EndProject
99
Global
1010
GlobalSection(SolutionConfigurationPlatforms) = preSolution

src/dotenv.net/DotEnv.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@
33

44
namespace dotenv.net;
55

6+
/// <summary>
7+
/// Provides static methods to configure, read, and load environment variables from .env files.
8+
/// </summary>
69
public static class DotEnv
710
{
811
/// <summary>
9-
/// Initialize the fluent configuration API
12+
/// Initialises the fluent configuration API.
1013
/// </summary>
14+
/// <returns>A new instance of <see cref="DotEnvOptions" />.</returns>
1115
public static DotEnvOptions Fluent() => new();
1216

1317
/// <summary>
14-
/// Read and return the values in the provided env files
18+
/// Reads the values from the provided env files based on the specified options.
1519
/// </summary>
16-
/// <param name="options">The options required to configure the env loader</param>
17-
/// <returns>The key value pairs read from the env files</returns>
20+
/// <param name="options">The options required to configure the env loader. If null, default options are used.</param>
21+
/// <returns>A dictionary containing the key-value pairs read from the env files.</returns>
1822
public static IDictionary<string, string> Read(DotEnvOptions? options = null)
1923
{
2024
options ??= new DotEnvOptions();
@@ -35,9 +39,9 @@ public static IDictionary<string, string> Read(DotEnvOptions? options = null)
3539
}
3640

3741
/// <summary>
38-
/// Load the values in the provided env files into the environment variables
42+
/// Loads the values from the provided env files into the system environment variables.
3943
/// </summary>
40-
/// <param name="options">The options required to configure the env loader</param>
44+
/// <param name="options">The options required to configure the env loader. If null, default options are used.</param>
4145
public static void Load(DotEnvOptions? options = null)
4246
{
4347
options ??= new DotEnvOptions();

0 commit comments

Comments
 (0)