Skip to content

Commit 3ea9a8b

Browse files
committed
Merge branch 'main' into pr/3
2 parents fb9f4e3 + bb71d8a commit 3ea9a8b

23 files changed

+662
-589
lines changed

.clang-format

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
UseTab: Never
2+
TabWidth: 2
3+
ColumnLimit: 110
4+
AlignAfterOpenBracket: AlwaysBreak
5+
AlignOperands: Align
6+
AlignTrailingComments: false
7+
BraceWrapping:
8+
AfterControlStatement: true
9+
BeforeElse: true
10+
AfterFunction: true
11+
BeforeCatch: true
12+
BeforeLambdaBody: true
13+
BeforeWhile: true
14+
AfterClass: true
15+
AfterEnum: true
16+
AfterStruct: true
17+
AfterUnion: true
18+
BreakBeforeBraces: Allman
19+
MaxEmptyLinesToKeep: 1
20+
NamespaceIndentation: All
21+
IndentCaseLabels: true
22+
AllowShortIfStatementsOnASingleLine: false
23+
AllowShortBlocksOnASingleLine: Never
24+
SortUsingDeclarations: LexicographicNumeric
25+
AllowShortCaseExpressionOnASingleLine: false
26+
AllowShortCaseLabelsOnASingleLine: false
27+
AllowShortCompoundRequirementOnASingleLine: false
28+
AllowShortEnumsOnASingleLine: false
29+
AllowShortFunctionsOnASingleLine: false
30+
AllowShortLambdasOnASingleLine: false
31+
AllowShortLoopsOnASingleLine: false
32+
AllowShortNamespacesOnASingleLine: false

Docs/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ module.exports = {
6464
{ title: 'License', path: 'license', icon: 'copyright' }
6565
],
6666

67-
footer: '© ' + new Date().getFullYear() + ' <a href="https://dervis.de">Cemalettin Dervis</a>',
67+
footer: '© ' + new Date().getFullYear() + ' <a href="https://dervis.de">Cem Dervis</a>',
6868
madeWithDocmd: 'Made with',
6969

7070
favicon: '/assets/images/favicon.ico',

Docs/docs/license.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ SharpConfig is licensed under the [MIT license](https://choosealicense.com/licen
77
```
88
MIT License
99
10-
Copyright (c) 2013-2025 Cemalettin Dervis
10+
Copyright (c) 2013-2025 Cem Dervis
1111
1212
Permission is hereby granted, free of charge, to any person obtaining a copy
1313
of this software and associated documentation files (the "Software"), to deal

Example/Program.cs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Copyright (c) 2013-2022 Cemalettin Dervis, MIT License.
2-
// https://github.com/cemdervis/SharpConfig
1+
// Copyright (c) 2013-2025 Cem Dervis, MIT License.
2+
// https://sharpconfig.org
33

44
using SharpConfig;
55

@@ -31,12 +31,11 @@ public static void Main()
3131

3232
// HowToLoadAConfig();
3333
// HowToCreateAConfig();
34-
// HowToSaveAConfig(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "TestCfg.ini"));
34+
// HowToSaveAConfig(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
35+
// "TestCfg.ini"));
3536
// HowToCreateObjectsFromSections();
3637
// HowToCreateSectionsFromObjects();
3738
// HowToHandleArrays();
38-
39-
Console.ReadLine();
4039
}
4140

4241
/// <summary>
@@ -47,7 +46,7 @@ public static void Main()
4746
private static void HowToLoadAConfig()
4847
{
4948
// Read our example config.
50-
Configuration cfg = Configuration.LoadFromFile("SampleCfg.txt");
49+
var cfg = Configuration.LoadFromFile("SampleCfg.txt");
5150

5251
// Just print all sections and their settings.
5352
PrintConfig(cfg);
@@ -126,12 +125,11 @@ private static void HowToCreateSectionsFromObjects()
126125
var cfg = new Configuration();
127126

128127
// Create an object.
129-
var p = new SomeClass
130-
{
128+
var p = new SomeClass {
131129
SomeString = "foobar",
132130
SomeInt = 2000,
133131
SomeInts = new[] { 1, 2, 3 },
134-
SomeDate = DateTime.Now
132+
SomeDate = DateTime.Now,
135133
};
136134

137135
// Now create a section from it.
@@ -151,12 +149,12 @@ private static void HowToHandleArrays()
151149
cfg["GeneralSection"]["SomeInts"].IntValueArray = new[] { 1, 2, 3 };
152150

153151
// Get the array back.
154-
int[] someIntValuesBack = cfg["GeneralSection"]["SomeInts"].GetValueArray<int>();
155-
float[] sameValuesButFloats = cfg["GeneralSection"]["SomeInts"].GetValueArray<float>();
156-
string[] sameValuesButStrings = cfg["GeneralSection"]["SomeInts"].GetValueArray<string>();
152+
var someIntValuesBack = cfg["GeneralSection"]["SomeInts"].GetValueArray<int>();
153+
var sameValuesButFloats = cfg["GeneralSection"]["SomeInts"].GetValueArray<float>();
154+
var sameValuesButStrings = cfg["GeneralSection"]["SomeInts"].GetValueArray<string>();
157155

158156
// There is also a non-generic variant of GetValueArray:
159-
object[] sameValuesButObjects = cfg["GeneralSection"]["SomeInts"].GetValueArray(typeof(int));
157+
var sameValuesButObjects = cfg["GeneralSection"]["SomeInts"].GetValueArray(typeof(int));
160158

161159
PrintArray("someIntValuesBack", someIntValuesBack);
162160
PrintArray("sameValuesButFloats", sameValuesButFloats);
@@ -170,7 +168,7 @@ private static void HowToHandleArrays()
170168
/// <param name="cfg">The configuration to print.</param>
171169
private static void PrintConfig(Configuration cfg)
172170
{
173-
foreach (Section section in cfg)
171+
foreach (var section in cfg)
174172
{
175173
Console.WriteLine("[{0}]", section.Name);
176174

@@ -179,7 +177,9 @@ private static void PrintConfig(Configuration cfg)
179177
Console.Write(" ");
180178

181179
if (setting.IsArray)
180+
{
182181
Console.Write("[Array, {0} elements] ", setting.ArraySize);
182+
}
183183

184184
Console.WriteLine(setting.ToString());
185185
}
@@ -194,7 +194,9 @@ private static void PrintArray<T>(string arrName, IReadOnlyList<T> arr)
194194
Console.Write(arrName + " = { ");
195195

196196
for (int i = 0; i < arr.Count - 1; i++)
197+
{
197198
Console.Write(arr[i] + ", ");
199+
}
198200

199201
Console.Write(arr[^1]!.ToString());
200202
Console.WriteLine(" }");

FormatAll.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Convenience script that formats all known source files in SharpConfig.
2+
# Simply call this from the SharpConfig root folder, e.g.:
3+
#
4+
# > python FormatAll.py
5+
6+
import os
7+
8+
def formatSourcesIn(dir: str):
9+
for root, dirs, files in os.walk(dir):
10+
if 'bin' in root or 'obj' in root:
11+
continue
12+
13+
print('-', root)
14+
for filename in files:
15+
if filename.endswith('.cs'):
16+
print(' -', filename)
17+
os.system(f'clang-format -i {os.path.join(root, filename)}')
18+
19+
20+
print('Formatting all known source files...')
21+
22+
for folder in ['Src', 'Example', 'Tests']:
23+
formatSourcesIn(folder)
24+
25+
print('Formatting finished')

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2013-2025 Cemalettin Dervis
3+
Copyright (c) 2013-2025 Cem Dervis
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
**Easy to use cfg / ini configuration library for .NET.**
88

99
You can use SharpConfig to read, modify and save configuration files and streams, in either text or binary format.
10-
Fully portable, zero package dependencies.
10+
Minimalistic, fully portable ([.NET Standard 2.0](https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0#select-net-standard-version)), zero package dependencies.
1111

1212
[![Homepage](https://img.shields.io/badge/Homepage-blue)](https://dervis.de/sharpconfig)
1313
[![NuGet Version](https://img.shields.io/nuget/v/sharpconfig)](https://www.nuget.org/packages/sharpconfig)

0 commit comments

Comments
 (0)