Lesson 1 with .net .gitignore and clean repo

This commit is contained in:
2025-11-28 15:11:41 -06:00
commit 3dc91c2fe8
8 changed files with 291 additions and 0 deletions

133
.gitignore vendored Normal file
View File

@@ -0,0 +1,133 @@
## -----------------------------
## .NET build artifacts
## -----------------------------
# Build output
bin/
obj/
# Publish output
*.publish/
publish/
# NuGet packages
*.nupkg
*.snupkg
packages/
# For local NuGet sources
*.nuspec
## -----------------------------
## IDE / Editor Specific
## -----------------------------
# Visual Studio (Windows)
.vs/
# Rider (JetBrains)
.idea/
*.sln.iml
# VS Code
.vscode/
*.code-workspace
# OmniSharp & Roslyn temp cache
.omnisharp/
.vscode-test/
## -----------------------------
## OS-specific junk
## -----------------------------
# Windows Explorer
Thumbs.db
Desktop.ini
# macOS Finder
.DS_Store
# Linux temp files
*~
## -----------------------------
## Logs / Temp / Runtime
## -----------------------------
# Logs
*.log
# DotNet watcher temp
.dotnet/
# User-specific config/generated files
*.user
*.userosscache
*.suo
# Auto-generated by Visual Studio
*.cache/
*.pdb
*.mdb
## -----------------------------
## Test / Coverage tools
## -----------------------------
# Coverlet
coverage.json
coverage.opencover.xml
coverage.cobertura.xml
# Test results
TestResults/
*.trx
# NCrunch
_NCrunch_*
*ncrunchsolution*
## -----------------------------
## Build system artifacts
## -----------------------------
# MSBuild artifacts
*.obj
*.cache
*.tlog
# Rider MSBuild artifacts
riderModule.iml
## -----------------------------
## Secret or runtime config
## -----------------------------
# DO NOT COMMIT real secrets automatically
# (user credentials, API keys, etc)
secrets.json
# Local environment files
.env
.env.*.local
## -----------------------------
## Misc things we also don't want
## -----------------------------
# Local tools
tools/
# Artifacts folders
artifacts/
dist/
out/
# Crash dumps
*.dmp
*.stackdump
# Package restore metadata
project.lock.json
project.fragment.lock.json

39
NetPulse.sln Normal file
View File

@@ -0,0 +1,39 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827E0CD3-B72D-47B6-A68D-7590B98EB39B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetPulse.Core", "src\NetPulse.Core\NetPulse.Core.csproj", "{B996D138-9747-4AE9-9FEB-586D6F9CD97E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B996D138-9747-4AE9-9FEB-586D6F9CD97E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B996D138-9747-4AE9-9FEB-586D6F9CD97E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B996D138-9747-4AE9-9FEB-586D6F9CD97E}.Debug|x64.ActiveCfg = Debug|Any CPU
{B996D138-9747-4AE9-9FEB-586D6F9CD97E}.Debug|x64.Build.0 = Debug|Any CPU
{B996D138-9747-4AE9-9FEB-586D6F9CD97E}.Debug|x86.ActiveCfg = Debug|Any CPU
{B996D138-9747-4AE9-9FEB-586D6F9CD97E}.Debug|x86.Build.0 = Debug|Any CPU
{B996D138-9747-4AE9-9FEB-586D6F9CD97E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B996D138-9747-4AE9-9FEB-586D6F9CD97E}.Release|Any CPU.Build.0 = Release|Any CPU
{B996D138-9747-4AE9-9FEB-586D6F9CD97E}.Release|x64.ActiveCfg = Release|Any CPU
{B996D138-9747-4AE9-9FEB-586D6F9CD97E}.Release|x64.Build.0 = Release|Any CPU
{B996D138-9747-4AE9-9FEB-586D6F9CD97E}.Release|x86.ActiveCfg = Release|Any CPU
{B996D138-9747-4AE9-9FEB-586D6F9CD97E}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{B996D138-9747-4AE9-9FEB-586D6F9CD97E} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,45 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace NetPulse.Core;
public class EngineLoop : BackgroundService
{
private readonly ILogger<EngineLoop> _logger;
private readonly TimeSpan _interval = TimeSpan.FromSeconds(2);
public EngineLoop(ILogger<EngineLoop> logger)
{
_logger = logger;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
_logger.LogInformation("EngineLoop started.");
while(!stoppingToken.IsCancellationRequested)
{
try
{
// ===== Core Heartbeat =====
_logger.LogInformation("Hearbeat at {time}", DateTime.UtcNow);
// Future: metrics Collection
// Future: dispatch events
// Future: run modules
await Task.Delay(_interval, stoppingToken);
}
catch (TaskCanceledException)
{
break;
}
catch (Exception ex)
{
_logger.LogError(ex, "Unexpected Engine error.");
}
}
_logger.LogInformation("EngineLoop Stopping");
}
}

View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>dotnet-NetPulse.Core-d06ed89e-b585-4482-b09d-8e11e4e6f936</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.9" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,33 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Configuration;
namespace NetPulse.Core;
public class Program
{
public static async Task Main(string[] args)
{
using IHost host = Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration(config =>
{
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
})
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.AddSimpleConsole(options =>
{
options.TimestampFormat = "HH:MM:SS";
options.IncludeScopes = true;
});
})
.ConfigureServices((context, services) =>
{
services.AddHostedService<EngineLoop>();
})
.Build();
await host.RunAsync();
}
}

View File

@@ -0,0 +1,12 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"NetPulse.Core": {
"commandName": "Project",
"dotnetRunMessages": true,
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development"
}
}
}
}

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}