Skip to content

Commit dd94149

Browse files
author
Alexis Huvier
authored
Merge pull request #1 from betofloresbaca/add-formatting-on-commit
Add formatting on commit
2 parents 574b25a + 2f8acc0 commit dd94149

File tree

8 files changed

+119
-58
lines changed

8 files changed

+119
-58
lines changed

.config/dotnet-tools.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"husky": {
6+
"version": "0.6.2",
7+
"commands": [
8+
"husky"
9+
]
10+
},
11+
"csharpier": {
12+
"version": "0.25.0",
13+
"commands": [
14+
"dotnet-csharpier"
15+
]
16+
}
17+
}
18+
}

.husky/pre-commit

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
## husky task runner examples -------------------
5+
## Note : for local installation use 'dotnet' prefix. e.g. 'dotnet husky'
6+
7+
## run all tasks
8+
#husky run
9+
10+
### run all tasks with group: 'group-name'
11+
#husky run --group group-name
12+
13+
## run task with name: 'task-name'
14+
#husky run --name task-name
15+
16+
## pass hook arguments to task
17+
#husky run --args "$1" "$2"
18+
19+
## or put your custom commands -------------------
20+
#echo 'Husky.Net is awesome!'
21+
22+
dotnet husky run --name format

.husky/task-runner.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"tasks": [
3+
{
4+
"name": "format",
5+
"command": "dotnet",
6+
"args": [ "csharpier", "${staged}" ],
7+
"include": [ "**/*.cs" ]
8+
}
9+
]
10+
}

SharpEngine.SQLite/SESQLite.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@ public static void AddVersions()
1515
DebugManager.Versions.Add("System.Data.SQLite", "1.0.118");
1616
DebugManager.Versions.Add("SharpEngine.SQLite", "1.0.0");
1717
}
18-
19-
}
18+
}

SharpEngine.SQLite/SQLiteDataTable.cs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ namespace SharpEngine.SQLite;
66
/// <summary>
77
/// Sqlite Data Table
88
/// </summary>
9-
public class SQLiteDataTable<T>: IDataTable where T : new()
9+
public class SQLiteDataTable<T> : IDataTable
10+
where T : new()
1011
{
1112
private List<dynamic> Objects { get; }
12-
13+
1314
/// <summary>
1415
/// Create Data Table from SQLite
1516
/// </summary>
@@ -19,33 +20,37 @@ namespace SharpEngine.SQLite;
1920
public SQLiteDataTable(string dbFile, string version = "3")
2021
{
2122
Objects = new List<dynamic>();
22-
23-
var connection = new SQLiteConnection($"Data Source={dbFile};Version={version};New=True;Compress=True;");
24-
23+
24+
var connection = new SQLiteConnection(
25+
$"Data Source={dbFile};Version={version};New=True;Compress=True;"
26+
);
27+
2528
connection.Open();
26-
29+
2730
var cmd = connection.CreateCommand();
2831
cmd.CommandText = $"SELECT * FROM {typeof(T).Name};";
2932
var reader = cmd.ExecuteReader();
3033
while (reader.Read())
3134
{
3235
var obj = new T();
33-
36+
3437
var index = 0;
3538
foreach (var property in typeof(T).GetProperties())
3639
{
37-
if(reader.IsDBNull(index))
40+
if (reader.IsDBNull(index))
3841
property.SetValue(obj, null);
39-
else if(property.PropertyType == typeof(string))
42+
else if (property.PropertyType == typeof(string))
4043
property.SetValue(obj, reader.GetString(index));
41-
else if(property.PropertyType == typeof(int))
44+
else if (property.PropertyType == typeof(int))
4245
property.SetValue(obj, reader.GetInt32(index));
43-
else if(property.PropertyType == typeof(bool))
46+
else if (property.PropertyType == typeof(bool))
4447
property.SetValue(obj, reader.GetBoolean(index));
4548
else if (property.PropertyType == typeof(float))
4649
property.SetValue(obj, reader.GetFloat(index));
4750
else
48-
throw new NotImplementedException($"Not implemented type : {property.PropertyType.Name}");
51+
throw new NotImplementedException(
52+
$"Not implemented type : {property.PropertyType.Name}"
53+
);
4954
index++;
5055
}
5156
Objects.Add(obj);
@@ -58,4 +63,4 @@ public SQLiteDataTable(string dbFile, string version = "3")
5863
{
5964
return Objects.Find(predicate);
6065
}
61-
}
66+
}
Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net7.0</TargetFramework>
4+
<ImplicitUsings>enable</ImplicitUsings>
5+
<Nullable>enable</Nullable>
6+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
7+
<Description>SQLite Package of SharpEngine - 2D Game Engine</Description>
8+
<PackageProjectUrl />
9+
<Authors>LavaPower</Authors>
10+
<Company>LavaPower</Company>
11+
<Copyright>Copyright (c) LavaPower 2021-2023</Copyright>
12+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
13+
<PackageProjectUrl>https://github.com/SharpEngine/SharpEngine.SQLite</PackageProjectUrl>
14+
<PackageVersion>1.0.0</PackageVersion>
15+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
16+
<PackageReadmeFile>README.md</PackageReadmeFile>
17+
<EnablePackageValisation>true</EnablePackageValisation>
18+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
19+
<RepositoryUrl>https://github.com/SharpEngine/SharpEngine.SQLite</RepositoryUrl>
20+
<RepositoryType>git</RepositoryType>
21+
<PackageTags>SQLite,SharpEngine,Game,Engine</PackageTags>
22+
</PropertyGroup>
23+
<ItemGroup>
24+
<None Include="../CHANGELOG.md" Pack="true" PackagePath="\" />
25+
<None Include="../README.md" Pack="true" PackagePath="\" />
26+
</ItemGroup>
27+
<ItemGroup>
28+
<PackageReference Include="SharpEngine.Core" Version="1.1.2" />
29+
<PackageReference Include="System.Data.SQLite" Version="1.0.118" />
30+
</ItemGroup>
231

3-
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
7-
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
8-
<Description>SQLite Package of SharpEngine - 2D Game Engine</Description>
9-
<PackageProjectUrl />
10-
<Authors>LavaPower</Authors>
11-
<Company>LavaPower</Company>
12-
<Copyright>Copyright (c) LavaPower 2021-2023</Copyright>
13-
<PackageLicenseExpression>MIT</PackageLicenseExpression>
14-
<PackageProjectUrl>https://github.com/SharpEngine/SharpEngine.SQLite</PackageProjectUrl>
15-
<PackageVersion>1.0.0</PackageVersion>
16-
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
17-
<PackageReadmeFile>README.md</PackageReadmeFile>
18-
<EnablePackageValisation>true</EnablePackageValisation>
19-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
20-
<RepositoryUrl>https://github.com/SharpEngine/SharpEngine.SQLite</RepositoryUrl>
21-
<RepositoryType>git</RepositoryType>
22-
<PackageTags>SQLite,SharpEngine,Game,Engine</PackageTags>
23-
</PropertyGroup>
24-
25-
<ItemGroup>
26-
<None Include="../CHANGELOG.md" Pack="true" PackagePath="\" />
27-
<None Include="../README.md" Pack="true" PackagePath="\" />
28-
</ItemGroup>
29-
30-
<ItemGroup>
31-
<PackageReference Include="SharpEngine.Core" Version="1.1.2" />
32-
<PackageReference Include="System.Data.SQLite" Version="1.0.118" />
33-
</ItemGroup>
34-
</Project>
32+
<!-- set HUSKY to 0 in CI\/CD disable this -->
33+
<Target Name="Husky" BeforeTargets="Restore;CollectPackageReferences" Condition="'$(HUSKY)' != 0">
34+
<Exec Command="dotnet tool restore" StandardOutputImportance="Low" StandardErrorImportance="High" />
35+
<Exec Command="dotnet husky install" StandardOutputImportance="Low" StandardErrorImportance="High" WorkingDirectory=".." />
36+
</Target>
37+
</Project>

Testing/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// See https://aka.ms/new-console-template for more information
22

3-
Console.WriteLine("Hello, World!");
3+
Console.WriteLine("Hello, World!");

Testing/Testing.csproj

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>net7.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
28

3-
<PropertyGroup>
4-
<OutputType>Exe</OutputType>
5-
<TargetFramework>net7.0</TargetFramework>
6-
<ImplicitUsings>enable</ImplicitUsings>
7-
<Nullable>enable</Nullable>
8-
</PropertyGroup>
9-
10-
</Project>
9+
<!-- set HUSKY to 0 in CI\/CD disable this -->
10+
<Target Name="Husky" BeforeTargets="Restore;CollectPackageReferences" Condition="'$(HUSKY)' != 0">
11+
<Exec Command="dotnet tool restore" StandardOutputImportance="Low" StandardErrorImportance="High" />
12+
<Exec Command="dotnet husky install" StandardOutputImportance="Low" StandardErrorImportance="High" WorkingDirectory=".." />
13+
</Target>
14+
</Project>

0 commit comments

Comments
 (0)