commit 0da8abdeca19bf0b4c690bde380fc905b3313a23 Author: MasterGordon Date: Tue Oct 25 13:31:07 2022 +0200 init diff --git a/boulder-dash/.github/workflows/dotnet.yml b/boulder-dash/.github/workflows/dotnet.yml new file mode 100644 index 0000000..7beca10 --- /dev/null +++ b/boulder-dash/.github/workflows/dotnet.yml @@ -0,0 +1,32 @@ +name: .NET + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + - name: Publish + run: dotnet publish -r linux-x64 + - name: Upload a Build Artifact + uses: actions/upload-artifact@v3.1.0 + with: + # Artifact name + name: Linux build + # A file, directory or wildcard pattern that describes what to upload + path: bin/Debug/net6.0/linux-x64/publish/asdlteroids diff --git a/boulder-dash/.gitignore b/boulder-dash/.gitignore new file mode 100644 index 0000000..cd42ee3 --- /dev/null +++ b/boulder-dash/.gitignore @@ -0,0 +1,2 @@ +bin/ +obj/ diff --git a/boulder-dash/Program.cs b/boulder-dash/Program.cs new file mode 100644 index 0000000..6a63dee --- /dev/null +++ b/boulder-dash/Program.cs @@ -0,0 +1,10 @@ +class Program +{ + static void Main(string[] args) + { + // bool isHost = args.Contains("--host"); + bool isHost = true; + var game = new MultiPlayerGame(isHost); + game.Run(); + } +} diff --git a/boulder-dash/assets/explode.wav b/boulder-dash/assets/explode.wav new file mode 100644 index 0000000..0741f66 Binary files /dev/null and b/boulder-dash/assets/explode.wav differ diff --git a/boulder-dash/assets/font.ttf b/boulder-dash/assets/font.ttf new file mode 100644 index 0000000..39adf42 Binary files /dev/null and b/boulder-dash/assets/font.ttf differ diff --git a/boulder-dash/assets/level1.json b/boulder-dash/assets/level1.json new file mode 100644 index 0000000..a1d7a45 --- /dev/null +++ b/boulder-dash/assets/level1.json @@ -0,0 +1,90 @@ +[ + [ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + ], + [ + 1, 2, 2, 2, 2, 2, 2, 0, 2, 2, 3, 2, 4, 0, 2, 2, 2, 2, 2, 4, 2, 4, 2, 2, 2, + 2, 2, 2, 2, 0, 2, 2, 2, 2, 4, 2, 2, 2, 2, 1 + ], + [ + 1, 2, 4, 9, 4, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 3, 2, 2, + 4, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 0, 2, 2, 1 + ], + [ + 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 0, 2, 2, 2, 2, 2, 4, 2, 4, 2, 2, + 4, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 1 + ], + [ + 1, 4, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 4, 2, 2, 4, + 2, 2, 2, 2, 4, 2, 2, 2, 4, 2, 2, 2, 2, 2, 1 + ], + [ + 1, 4, 2, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 2, 2, 4, 2, 2, 2, 2, 2, 2, + 2, 2, 4, 2, 2, 2, 2, 2, 2, 4, 2, 4, 0, 2, 1 + ], + [ + 1, 2, 2, 2, 4, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 4, 2, 0, + 4, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 4, 4, 2, 1 + ], + [ + 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 2, 2, 2, 4, 2, 2, 4, 2, 1 + ], + [ + 1, 2, 0, 2, 2, 2, 4, 2, 2, 3, 2, 0, 2, 2, 4, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 3, 2, 4, 0, 2, 2, 2, 2, 2, 2, 4, 2, 1 + ], + [ + 1, 2, 2, 3, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 4, + 0, 0, 4, 2, 2, 3, 2, 2, 2, 2, 4, 2, 2, 2, 1 + ], + [ + 1, 2, 2, 2, 4, 2, 2, 4, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, + 4, 2, 4, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 1 + ], + [ + 1, 2, 0, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 2, 2, 2, 2, 2, 2, + 2, 2, 4, 2, 2, 4, 2, 3, 2, 2, 2, 2, 0, 2, 1 + ], + [ + 1, 2, 4, 2, 2, 2, 2, 2, 4, 2, 2, 0, 0, 2, 2, 2, 2, 4, 2, 4, 3, 2, 2, 3, 2, + 2, 2, 2, 4, 2, 2, 2, 4, 2, 2, 3, 2, 4, 2, 1 + ], + [ + 1, 2, 3, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 2, 2, 4, 2, + 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 4, 1 + ], + [ + 1, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1 + ], + [ + 1, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 3, 2, 2, 2, 2, 4, 2, 2, 2, + 2, 2, 4, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 1 + ], + [ + 1, 0, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 2, 2, 4, 2, 2, 0, 0, 0, 2, 2, 2, + 4, 2, 2, 2, 2, 2, 2, 4, 2, 4, 0, 2, 2, 1, 1 + ], + [ + 1, 2, 4, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 4, 2, 0, 0, 2, + 2, 2, 2, 3, 2, 2, 2, 4, 2, 4, 4, 2, 2, 2, 1 + ], + [ + 1, 2, 2, 2, 2, 4, 3, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, + 4, 2, 4, 3, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 1 + ], + [ + 1, 2, 2, 2, 0, 2, 2, 0, 2, 4, 2, 2, 4, 2, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 4, 2, 4, 3, 2, 2, 2, 2, 2, 2, 4, 2, 2, 4, 1 + ], + [ + 1, 2, 3, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, + 4, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 1 + ], + [ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + ] +] diff --git a/boulder-dash/assets/shot.wav b/boulder-dash/assets/shot.wav new file mode 100644 index 0000000..7de2c5f Binary files /dev/null and b/boulder-dash/assets/shot.wav differ diff --git a/boulder-dash/assets/sprites.png b/boulder-dash/assets/sprites.png new file mode 100644 index 0000000..d83727a Binary files /dev/null and b/boulder-dash/assets/sprites.png differ diff --git a/boulder-dash/boulder-dash.csproj b/boulder-dash/boulder-dash.csproj new file mode 100644 index 0000000..c261002 --- /dev/null +++ b/boulder-dash/boulder-dash.csproj @@ -0,0 +1,23 @@ + + + + Exe + net6.0 + boulder-dash + enable + true + true + true + enable + + + + + + + + + + + + diff --git a/boulder-dash/readme.md b/boulder-dash/readme.md new file mode 100644 index 0000000..f95b8f4 --- /dev/null +++ b/boulder-dash/readme.md @@ -0,0 +1,2 @@ +# Boulder Dash SDL + diff --git a/boulder-dash/src/Context.cs b/boulder-dash/src/Context.cs new file mode 100644 index 0000000..1998ffd --- /dev/null +++ b/boulder-dash/src/Context.cs @@ -0,0 +1,41 @@ +class Context +{ + public bool IsHost { get; set; } + public IBackend Backend { get; set; } + public IFrontend Frontend { get; set; } + public GameState GameState { get; set; } + public FrontendGameState FrontendGameState { get; set; } + public Window Window { get; set; } + public Renderer Renderer { get; set; } + public static Context? instance { get; set; } + + public Context( + bool isHost, + IBackend backend, + IFrontend frontend, + GameState gameState, + FrontendGameState frontendGameState, + Renderer renderer, + Window window + ) + { + this.IsHost = isHost; + this.Backend = backend; + this.Frontend = frontend; + this.GameState = gameState; + this.FrontendGameState = frontendGameState; + this.Renderer = renderer; + this.Window = window; + Context.instance = this; + } + + public static Context Get() + { + if (Context.instance == null) + { + throw new Exception("Context not initialized"); + } + + return Context.instance; + } +} diff --git a/boulder-dash/src/Controls.cs b/boulder-dash/src/Controls.cs new file mode 100644 index 0000000..9ffc27a --- /dev/null +++ b/boulder-dash/src/Controls.cs @@ -0,0 +1,35 @@ +using static SDL2.SDL; + +enum Control +{ + UP, + DOWN, + LEFT, + RIGHT, + STAY, + CONFIRM, +} + +static class ControlKeyExtension +{ + public static SDL_Keycode Key(this Control c) + { + switch (c) + { + case Control.UP: + return SDL_Keycode.SDLK_w; + case Control.DOWN: + return SDL_Keycode.SDLK_s; + case Control.LEFT: + return SDL_Keycode.SDLK_a; + case Control.RIGHT: + return SDL_Keycode.SDLK_d; + case Control.STAY: + return SDL_Keycode.SDLK_LCTRL; + case Control.CONFIRM: + return SDL_Keycode.SDLK_SPACE; + default: + throw new ArgumentException("Invalid control"); + } + } +} diff --git a/boulder-dash/src/MultiPlayerGame.cs b/boulder-dash/src/MultiPlayerGame.cs new file mode 100644 index 0000000..eb6667c --- /dev/null +++ b/boulder-dash/src/MultiPlayerGame.cs @@ -0,0 +1,45 @@ +class MultiPlayerGame : Game +{ + private Context ctx; + + public MultiPlayerGame(bool isHost) + { + var window = new Window("MultiPlayerGame", 1200, 800); + if (isHost) + { + this.ctx = new Context( + isHost, + new Backend(), + new Frontend(), + new GameState(), + new FrontendGameState(), + new Renderer(window), + window + ); + } + else + { + this.ctx = new Context( + isHost, + new RemoteBackend(), + new Frontend(), + new GameState(), + new FrontendGameState(), + new Renderer(window), + window + ); + } + ctx.Frontend.Init(); + ctx.Backend.Init(); + } + + protected override void draw() + { + ctx.Frontend.Process(); + } + + protected override void update(double dt) + { + ctx.Backend.Process(dt); + } +} diff --git a/boulder-dash/src/backend/Backend.cs b/boulder-dash/src/backend/Backend.cs new file mode 100644 index 0000000..3de3040 --- /dev/null +++ b/boulder-dash/src/backend/Backend.cs @@ -0,0 +1,73 @@ +using System.Numerics; +using System.Text; +using Newtonsoft.Json; +using WatsonTcp; + +class Backend : IBackend +{ + public void Process(double dt) + { + var ctx = Context.Get(); + ctx.GameState.PlayerPositions.ForEach(player => + { + player.position += player.movement; + }); + } + + public void ProcessPacket(ValueType packet) + { + var gameState = Context.Get().GameState; + if (packet is MovePacket movePacket) + { + if (gameState.PlayerPositions.Find(player => player.name == movePacket.playerName) is Player player) + { + player.movement = movePacket.movement; + } + } + if (packet is ConnectPacket connectPacket) + { + gameState.PlayerPositions.Add(new Player + { + name = connectPacket.playerName, + position = new Vector2(50, 50), + movement = new Vector2(0, 0) + }); + } + } + + public void Init() + { + Task.Run(Run); + } + + public void Run() + { + var server = new WatsonTcpServer("127.0.0.1", 42069); + server.Events.ClientConnected += this.clientConnected; + server.Events.ClientDisconnected += this.clientDisconnected; + server.Events.MessageReceived += this.messageReceived; + server.Start(); + } + + private void clientConnected(object? sender, ConnectionEventArgs args) + { + Console.WriteLine("Client connected: " + args.IpPort); + var gameState = Context.Get().GameState; + var json = JsonConvert.SerializeObject(gameState); + if (sender is WatsonTcpServer server) + { + server.Send(args.IpPort, Encoding.UTF8.GetBytes(json)); + } + } + + private void clientDisconnected(object? sender, DisconnectionEventArgs args) + { + Console.WriteLine("Client disconnected: " + args.IpPort); + } + + private void messageReceived(object? sender, MessageReceivedEventArgs args) + { + var message = Encoding.UTF8.GetString(args.Data); + Console.WriteLine("Message received: " + args.IpPort + " " + message); + } +} diff --git a/boulder-dash/src/backend/IBackend.cs b/boulder-dash/src/backend/IBackend.cs new file mode 100644 index 0000000..4533116 --- /dev/null +++ b/boulder-dash/src/backend/IBackend.cs @@ -0,0 +1,6 @@ +interface IBackend +{ + public void Process(double dt); + public void ProcessPacket(ValueType packet); + public void Init(); +} diff --git a/boulder-dash/src/backend/RemoteBackend.cs b/boulder-dash/src/backend/RemoteBackend.cs new file mode 100644 index 0000000..a74ac76 --- /dev/null +++ b/boulder-dash/src/backend/RemoteBackend.cs @@ -0,0 +1,17 @@ +class RemoteBackend : IBackend +{ + public void Process(double dt) + { + + } + + public void ProcessPacket(ValueType packet) + { + throw new NotImplementedException(); + } + + public void Init() + { + + } +} diff --git a/boulder-dash/src/backend/data/Packet.cs b/boulder-dash/src/backend/data/Packet.cs new file mode 100644 index 0000000..d906260 --- /dev/null +++ b/boulder-dash/src/backend/data/Packet.cs @@ -0,0 +1,25 @@ +using System.Numerics; + +readonly struct MovePacket +{ + readonly public string type = "move"; + readonly public string playerName; + readonly public Vector2 movement; + + public MovePacket(string playerName, Vector2 movement) + { + this.playerName = playerName; + this.movement = movement; + } +} + +readonly struct ConnectPacket +{ + public readonly string type = "connect"; + public readonly string playerName; + + public ConnectPacket(string playerName) + { + this.playerName = playerName; + } +} diff --git a/boulder-dash/src/engine/AudioPlayer.cs b/boulder-dash/src/engine/AudioPlayer.cs new file mode 100644 index 0000000..dec199e --- /dev/null +++ b/boulder-dash/src/engine/AudioPlayer.cs @@ -0,0 +1,27 @@ +enum Sound +{ +} + +class AudioPlayer +{ + private Dictionary audioFiles = new(); + private ResourceLoader resourceLoader = new(); + + public AudioPlayer() + { + SDL2.SDL_mixer.Mix_OpenAudio(44100, SDL2.SDL_mixer.MIX_DEFAULT_FORMAT, 2, 2048); + } + + public void Register(Sound name, string path) + { + var buffer = resourceLoader.LoadBytes(path); + this.audioFiles.Add(name, buffer); + } + + public void Play(Sound name) + { + var buffer = this.audioFiles[name]; + var sound = SDL2.SDL_mixer.Mix_QuickLoad_WAV(buffer); + SDL2.SDL_mixer.Mix_PlayChannel((int)name, sound, 0); + } +} diff --git a/boulder-dash/src/engine/FontManager.cs b/boulder-dash/src/engine/FontManager.cs new file mode 100644 index 0000000..ffcbbb1 --- /dev/null +++ b/boulder-dash/src/engine/FontManager.cs @@ -0,0 +1,35 @@ +using static SDL2.SDL_ttf; +using static SDL2.SDL; + +class FontManager +{ + private Dictionary fonts = new(); + private ResourceLoader resourceLoader; + + public FontManager(ResourceLoader resourceLoader) + { + this.resourceLoader = resourceLoader; + if (TTF_Init() != 0) + { + throw new Exception("TTF_Init failed"); + } + } + + public void RegisterFont(string name, string path, int fontSize) + { + if (fonts.ContainsKey(name)) return; + var res = resourceLoader.LoadToIntPtr(path); + var sdlBuffer = SDL_RWFromConstMem(res.ptr, res.size); + var font = TTF_OpenFontRW(sdlBuffer, 1, fontSize); + if (font == IntPtr.Zero) + { + throw new Exception("TTF_OpenFont failed"); + } + fonts.Add(name, font); + } + + public IntPtr GetFont(string name) + { + return fonts[name]; + } +} diff --git a/boulder-dash/src/engine/Game.cs b/boulder-dash/src/engine/Game.cs new file mode 100644 index 0000000..83d57b1 --- /dev/null +++ b/boulder-dash/src/engine/Game.cs @@ -0,0 +1,30 @@ +abstract class Game +{ + public const int TPS = 64; + private Queue fpsQueue = new Queue(); + protected abstract void update(double dt); + protected abstract void draw(); + + public void Run() + { + var tLast = DateTime.Now; + var tAcc = TimeSpan.Zero; + while (true) + { + var dt = DateTime.Now - tLast; + tLast = DateTime.Now; + tAcc += dt; + var fps = (int)(1 / dt.TotalSeconds); + fpsQueue.Enqueue(fps); + while (fpsQueue.Count > fps) + fpsQueue.Dequeue(); + while (tAcc >= TimeSpan.FromSeconds(1.0 / TPS)) + { + update(dt.TotalSeconds); + tAcc -= TimeSpan.FromSeconds(1.0 / TPS); + } + + draw(); + } + } +} diff --git a/boulder-dash/src/engine/Renderer.cs b/boulder-dash/src/engine/Renderer.cs new file mode 100644 index 0000000..dc19ddd --- /dev/null +++ b/boulder-dash/src/engine/Renderer.cs @@ -0,0 +1,107 @@ +using static SDL2.SDL; +using static SDL2.SDL_ttf; + +class Renderer +{ + private IntPtr renderer; + private IntPtr font; + private SDL_Color color; + + public Renderer(Window window) + { + this.renderer = SDL_CreateRenderer(window.GetWindow(), -1, SDL_RendererFlags.SDL_RENDERER_ACCELERATED); + } + + public void Clear() + { + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + SDL_RenderClear(renderer); + } + + public void Present() + { + SDL_RenderPresent(renderer); + } + + public void DrawRect(double x, double y, int w, int h) + { + this.DrawRect((int)x, (int)y, w, h); + } + + public void DrawRect(int x, int y, int w, int h) + { + SDL_Rect rect = new SDL_Rect(); + rect.x = x; + rect.y = y; + rect.w = w; + rect.h = h; + + SDL_RenderFillRect(renderer, ref rect); + } + + public void DrawLines(double[][] points) + { + SDL_Point[] sdlPoints = new SDL_Point[points.Length]; + for (int i = 0; i < points.Length; i++) + { + sdlPoints[i].x = (int)points[i][0]; + sdlPoints[i].y = (int)points[i][1]; + } + + SDL_RenderDrawLines(renderer, sdlPoints, points.Length); + } + + public void SetColor(int r, int g, int b, int a = 255) + { + SDL_SetRenderDrawColor(renderer, (byte)r, (byte)g, (byte)b, (byte)a); + } + + public void SetFont(IntPtr font, SDL_Color color) + { + this.font = font; + this.color = color; + } + + public void SetFont(IntPtr font, Color color) + { + this.font = font; + this.color = color.toSDLColor(); + } + + public void DrawText(string text, int x, int y, bool center = false) + { + var surfaceMessage = TTF_RenderText_Solid(this.font, text, this.color); + + var texture = SDL_CreateTextureFromSurface(this.renderer, surfaceMessage); + int width; + int height; + + SDL_QueryTexture(texture, out _, out _, out width, out height); + + SDL_Rect rect = new SDL_Rect(); + rect.x = x; + rect.y = y; + rect.w = width; + rect.h = height; + + if (center) + { + rect.x -= width / 2; + rect.y -= height / 2; + } + + SDL_RenderCopy(this.renderer, texture, IntPtr.Zero, ref rect); + SDL_DestroyTexture(texture); + SDL_FreeSurface(surfaceMessage); + } + + public IntPtr GetRaw() + { + return renderer; + } + + public IntPtr CreateTextureFromSurface(IntPtr surface) + { + return SDL_CreateTextureFromSurface(renderer, surface); + } +} diff --git a/boulder-dash/src/engine/ResourceLoader.cs b/boulder-dash/src/engine/ResourceLoader.cs new file mode 100644 index 0000000..0352418 --- /dev/null +++ b/boulder-dash/src/engine/ResourceLoader.cs @@ -0,0 +1,50 @@ +using System.Runtime.InteropServices; + +class ResourceLoader +{ + private string assemblyName; + + public ResourceLoader() + { + this.assemblyName = this.GetType().Assembly.GetName().Name!; + } + + public string LoadString(string resourceName) + { +#if (DEBUG) + Console.WriteLine("Loading resource: " + resourceName); + return File.ReadAllText(ToPath(resourceName)); +#endif + using var stream = this.GetType().Assembly.GetManifestResourceStream($"{this.assemblyName}.{resourceName}"); + using var reader = new StreamReader(stream!); + return reader.ReadToEnd(); + } + + public byte[] LoadBytes(string resourceName) + { + using var stream = this.GetType().Assembly.GetManifestResourceStream($"{this.assemblyName}.{resourceName}"); + using var memoryStream = new MemoryStream(); + stream!.CopyTo(memoryStream); + return memoryStream.ToArray(); + } + + public (IntPtr ptr, int size) LoadToIntPtr(string resourceName) + { + var bytes = this.LoadBytes(resourceName); + var handle = GCHandle.Alloc(bytes, GCHandleType.Pinned); + var ptr = handle.AddrOfPinnedObject(); + return (ptr, bytes.Length); + } + + public void SaveString(string resourceName, string content) + { + using var stream = new StreamWriter(ToPath(resourceName)); + stream.Write(content); + } + + private static string ToPath(string resourceName) + { + var s = resourceName.Split('.'); + return String.Join('/', s[..^1]) + "." + s[^1]; + } +} diff --git a/boulder-dash/src/engine/Window.cs b/boulder-dash/src/engine/Window.cs new file mode 100644 index 0000000..1f6c79c --- /dev/null +++ b/boulder-dash/src/engine/Window.cs @@ -0,0 +1,33 @@ +using static SDL2.SDL; + +class Window +{ + IntPtr window; + + public Window(string title, int w, int h) + { + window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h, SDL_WindowFlags.SDL_WINDOW_VULKAN | SDL_WindowFlags.SDL_WINDOW_RESIZABLE); + } + + public Window(string title, int x, int y, int w, int h, SDL_WindowFlags flags) + { + this.window = SDL_CreateWindow(title, x, y, w, h, flags); + } + + public void Dispose() + { + SDL_DestroyWindow(this.window); + } + + public IntPtr GetWindow() + { + return this.window; + } + + public (int width, int height) GetSize() + { + int w, h; + SDL_GetWindowSize(this.window, out w, out h); + return (w, h); + } +} diff --git a/boulder-dash/src/engine/system/EventPriority.cs b/boulder-dash/src/engine/system/EventPriority.cs new file mode 100644 index 0000000..3adb334 --- /dev/null +++ b/boulder-dash/src/engine/system/EventPriority.cs @@ -0,0 +1,9 @@ +enum EventPriority : int +{ + Lowest = 0, + Low = 1, + Normal = 2, + High = 3, + Highest = 4, + Important = 5, +} diff --git a/boulder-dash/src/engine/system/Events.cs b/boulder-dash/src/engine/system/Events.cs new file mode 100644 index 0000000..8086cb9 --- /dev/null +++ b/boulder-dash/src/engine/system/Events.cs @@ -0,0 +1,35 @@ +[AttributeUsage(AttributeTargets.Method)] +class OnECSEvent : Attribute +{ + public EventPriority Priority = EventPriority.Normal; +} + +class OnTickEvent : OnECSEvent +{ +} + +struct TickEvent +{ + public int Tick; +} + +class OnKeyDownEvent : OnECSEvent +{ + public SDL2.SDL.SDL_Scancode? Scancode; +} + +class KeyEvent +{ + public SDL2.SDL.SDL_Scancode Scancode; + public bool Canceled; +} + +class OnKeyUpEvent : OnECSEvent +{ + public SDL2.SDL.SDL_Scancode? Scancode; +} + +class OnMouseButtonDownEvent : OnECSEvent +{ + public SDL2.SDL.SDL_Scancode? Scancode; +} diff --git a/boulder-dash/src/engine/system/SystemRegistry.cs b/boulder-dash/src/engine/system/SystemRegistry.cs new file mode 100644 index 0000000..871d8e4 --- /dev/null +++ b/boulder-dash/src/engine/system/SystemRegistry.cs @@ -0,0 +1,28 @@ +class ECSystemRegistry +{ + private HashSet hybridSystems; + private HashSet clientSystems; + private HashSet serverSystems; + + public ECSystemRegistry() + { + hybridSystems = new HashSet(); + clientSystems = new HashSet(); + serverSystems = new HashSet(); + object obj = new object(); + } + + public void RegisterSystem(object system, ECSystemKind kind) + { + this.GetSystems(kind).Add(system); + } + + public HashSet GetSystems(ECSystemKind kind) => + kind switch + { + ECSystemKind.Hybrid => hybridSystems, + ECSystemKind.Client => clientSystems, + ECSystemKind.Server => serverSystems, + _ => throw new ArgumentException("Invalid ECSystemKind") + }; +} diff --git a/boulder-dash/src/engine/system/annotations/Service.cs b/boulder-dash/src/engine/system/annotations/Service.cs new file mode 100644 index 0000000..9c7ab27 --- /dev/null +++ b/boulder-dash/src/engine/system/annotations/Service.cs @@ -0,0 +1,17 @@ +enum ECSystemKind +{ + Client, + Server, + Hybrid +} + +[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] +class ECSystem : Attribute +{ + public ECSystemKind Kind; + + public ECSystem(ECSystemKind kind) + { + this.Kind = kind; + } +} diff --git a/boulder-dash/src/engine/utils/Color.cs b/boulder-dash/src/engine/utils/Color.cs new file mode 100644 index 0000000..7d82521 --- /dev/null +++ b/boulder-dash/src/engine/utils/Color.cs @@ -0,0 +1,32 @@ +using static SDL2.SDL; + +class Color +{ + int r, g, b, a; + + public Color(int r, int g, int b, int a) + { + this.r = r; + this.g = g; + this.b = b; + this.a = a; + } + + public Color(int r, int g, int b) + { + this.r = r; + this.g = g; + this.b = b; + this.a = 255; + } + + public SDL_Color toSDLColor() + { + SDL_Color color = new SDL_Color(); + color.r = (byte)r; + color.g = (byte)g; + color.b = (byte)b; + color.a = (byte)a; + return color; + } +} diff --git a/boulder-dash/src/engine/utils/Point.cs b/boulder-dash/src/engine/utils/Point.cs new file mode 100644 index 0000000..585457e --- /dev/null +++ b/boulder-dash/src/engine/utils/Point.cs @@ -0,0 +1,7 @@ +class Point +{ + public static double Distance(double x1, double y1, double x2, double y2) + { + return Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2)); + } +} diff --git a/boulder-dash/src/frontend/Frontend.cs b/boulder-dash/src/frontend/Frontend.cs new file mode 100644 index 0000000..57bf481 --- /dev/null +++ b/boulder-dash/src/frontend/Frontend.cs @@ -0,0 +1,85 @@ +using System.Numerics; +using static SDL2.SDL; + +class Frontend : IFrontend +{ + public void Init() + { + var conntectPacket = new ConnectPacket("Gordon"); + Context.Get().Backend.ProcessPacket(conntectPacket); + } + + public void Process() + { + var ctx = Context.Get(); + while (SDL_PollEvent(out var e) != 0) + { + if (e.type == SDL_EventType.SDL_QUIT) + { + System.Environment.Exit(0); + } + if (e.type == SDL_EventType.SDL_KEYDOWN && e.key.repeat == 0) + { + var movementInput = ctx.FrontendGameState.movementInput; + if (e.key.keysym.scancode == SDL_Scancode.SDL_SCANCODE_A) + { + movementInput.X -= 1; + } + if (e.key.keysym.scancode == SDL_Scancode.SDL_SCANCODE_D) + { + movementInput.X += 1; + } + if (e.key.keysym.scancode == SDL_Scancode.SDL_SCANCODE_W) + { + movementInput.Y -= 1; + } + if (e.key.keysym.scancode == SDL_Scancode.SDL_SCANCODE_S) + { + movementInput.Y += 1; + } + ctx.FrontendGameState.movementInput = movementInput; + } + if (e.type == SDL_EventType.SDL_KEYUP && e.key.repeat == 0) + { + var movementInput = ctx.FrontendGameState.movementInput; + if (e.key.keysym.scancode == SDL_Scancode.SDL_SCANCODE_A) + { + movementInput.X += 1; + } + if (e.key.keysym.scancode == SDL_Scancode.SDL_SCANCODE_D) + { + movementInput.X -= 1; + } + if (e.key.keysym.scancode == SDL_Scancode.SDL_SCANCODE_W) + { + movementInput.Y += 1; + } + if (e.key.keysym.scancode == SDL_Scancode.SDL_SCANCODE_S) + { + movementInput.Y -= 1; + } + ctx.FrontendGameState.movementInput = movementInput; + } + if (e.key.keysym.scancode is + SDL_Scancode.SDL_SCANCODE_A or SDL_Scancode.SDL_SCANCODE_D or SDL_Scancode.SDL_SCANCODE_W or SDL_Scancode.SDL_SCANCODE_S) + { + var movement = ctx.FrontendGameState.movementInput; + if (movement.Length() > 0) + movement = Vector2.Normalize(movement); + ctx.Backend.ProcessPacket(new MovePacket("Gordon", movement)); + } + if (e.key.keysym.scancode == SDL_Scancode.SDL_SCANCODE_ESCAPE) + { + System.Environment.Exit(0); + } + } + + ctx.Renderer.Clear(); + ctx.Renderer.SetColor(255, 0, 0, 255); + ctx.GameState.PlayerPositions.ForEach(player => + { + ctx.Renderer.DrawRect(player.position.X, player.position.Y, 10, 10); + }); + ctx.Renderer.Present(); + } +} diff --git a/boulder-dash/src/frontend/IFrontend.cs b/boulder-dash/src/frontend/IFrontend.cs new file mode 100644 index 0000000..06df2db --- /dev/null +++ b/boulder-dash/src/frontend/IFrontend.cs @@ -0,0 +1,5 @@ +interface IFrontend +{ + public void Process(); + public void Init(); +} diff --git a/boulder-dash/src/network/Converter.cs b/boulder-dash/src/network/Converter.cs new file mode 100644 index 0000000..f369b65 --- /dev/null +++ b/boulder-dash/src/network/Converter.cs @@ -0,0 +1,34 @@ +using System.Text; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json; + +class Converter +{ + public static ValueType ParsePacket(byte[] bytes) + { + var jsonString = Encoding.UTF8.GetString(bytes); + return ParsePacket(jsonString); + } + + public static ValueType ParsePacket(string jsonString) + { + var parsedRaw = JObject.Parse(jsonString); + var type = parsedRaw.GetValue("type"); + if (type == null) + { + throw new System.Exception("Packet has no type"); + } + var packetType = type.Value(); + return packetType switch + { + "move" => parsedRaw.ToObject(), + _ => throw new System.Exception("Unknown packet type") + }; + } + + public static byte[] SerializePacket(ValueType packet) + { + var jsonString = JsonConvert.SerializeObject(packet); + return Encoding.UTF8.GetBytes(jsonString); + } +} diff --git a/boulder-dash/src/state/GameState.cs b/boulder-dash/src/state/GameState.cs new file mode 100644 index 0000000..f3f8131 --- /dev/null +++ b/boulder-dash/src/state/GameState.cs @@ -0,0 +1,18 @@ +using System.Numerics; + +class Player +{ + public string name; + public Vector2 position; + public Vector2 movement; +} + +class FrontendGameState +{ + public Vector2 movementInput; +} + +class GameState +{ + public List PlayerPositions { get; set; } = new List(); +} diff --git a/cli-args/Program.cs b/cli-args/Program.cs new file mode 100644 index 0000000..e452f49 --- /dev/null +++ b/cli-args/Program.cs @@ -0,0 +1,10 @@ +class Program +{ + public static void Main(String[] args) + { + foreach (var arg in args) + { + Console.WriteLine(arg); + } + } +} diff --git a/cli-args/bin/Debug/net6.0/cli-args b/cli-args/bin/Debug/net6.0/cli-args new file mode 100755 index 0000000..6a34845 Binary files /dev/null and b/cli-args/bin/Debug/net6.0/cli-args differ diff --git a/cli-args/bin/Debug/net6.0/cli-args.deps.json b/cli-args/bin/Debug/net6.0/cli-args.deps.json new file mode 100644 index 0000000..f691527 --- /dev/null +++ b/cli-args/bin/Debug/net6.0/cli-args.deps.json @@ -0,0 +1,23 @@ +{ + "runtimeTarget": { + "name": ".NETCoreApp,Version=v6.0", + "signature": "" + }, + "compilationOptions": {}, + "targets": { + ".NETCoreApp,Version=v6.0": { + "cli-args/1.0.0": { + "runtime": { + "cli-args.dll": {} + } + } + } + }, + "libraries": { + "cli-args/1.0.0": { + "type": "project", + "serviceable": false, + "sha512": "" + } + } +} \ No newline at end of file diff --git a/cli-args/bin/Debug/net6.0/cli-args.dll b/cli-args/bin/Debug/net6.0/cli-args.dll new file mode 100644 index 0000000..3a25ef1 Binary files /dev/null and b/cli-args/bin/Debug/net6.0/cli-args.dll differ diff --git a/cli-args/bin/Debug/net6.0/cli-args.pdb b/cli-args/bin/Debug/net6.0/cli-args.pdb new file mode 100644 index 0000000..3283a4e Binary files /dev/null and b/cli-args/bin/Debug/net6.0/cli-args.pdb differ diff --git a/cli-args/bin/Debug/net6.0/cli-args.runtimeconfig.json b/cli-args/bin/Debug/net6.0/cli-args.runtimeconfig.json new file mode 100644 index 0000000..4986d16 --- /dev/null +++ b/cli-args/bin/Debug/net6.0/cli-args.runtimeconfig.json @@ -0,0 +1,9 @@ +{ + "runtimeOptions": { + "tfm": "net6.0", + "framework": { + "name": "Microsoft.NETCore.App", + "version": "6.0.0" + } + } +} \ No newline at end of file diff --git a/cli-args/cli-args.csproj b/cli-args/cli-args.csproj new file mode 100644 index 0000000..cc56b53 --- /dev/null +++ b/cli-args/cli-args.csproj @@ -0,0 +1,11 @@ + + + + Exe + net6.0 + cli_args + enable + enable + + + diff --git a/cli-args/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs b/cli-args/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs new file mode 100644 index 0000000..f795be5 --- /dev/null +++ b/cli-args/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")] diff --git a/cli-args/obj/Debug/net6.0/apphost b/cli-args/obj/Debug/net6.0/apphost new file mode 100755 index 0000000..6a34845 Binary files /dev/null and b/cli-args/obj/Debug/net6.0/apphost differ diff --git a/cli-args/obj/Debug/net6.0/cli-args.AssemblyInfo.cs b/cli-args/obj/Debug/net6.0/cli-args.AssemblyInfo.cs new file mode 100644 index 0000000..0bf824e --- /dev/null +++ b/cli-args/obj/Debug/net6.0/cli-args.AssemblyInfo.cs @@ -0,0 +1,22 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: System.Reflection.AssemblyCompanyAttribute("cli-args")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] +[assembly: System.Reflection.AssemblyProductAttribute("cli-args")] +[assembly: System.Reflection.AssemblyTitleAttribute("cli-args")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/cli-args/obj/Debug/net6.0/cli-args.AssemblyInfoInputs.cache b/cli-args/obj/Debug/net6.0/cli-args.AssemblyInfoInputs.cache new file mode 100644 index 0000000..6d7e27b --- /dev/null +++ b/cli-args/obj/Debug/net6.0/cli-args.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +1daa636f2fccb0338c228f257b0aa19d9e2dc078 diff --git a/cli-args/obj/Debug/net6.0/cli-args.GeneratedMSBuildEditorConfig.editorconfig b/cli-args/obj/Debug/net6.0/cli-args.GeneratedMSBuildEditorConfig.editorconfig new file mode 100644 index 0000000..5a6efeb --- /dev/null +++ b/cli-args/obj/Debug/net6.0/cli-args.GeneratedMSBuildEditorConfig.editorconfig @@ -0,0 +1,10 @@ +is_global = true +build_property.TargetFramework = net6.0 +build_property.TargetPlatformMinVersion = +build_property.UsingMicrosoftNETSdkWeb = +build_property.ProjectTypeGuids = +build_property.InvariantGlobalization = +build_property.PlatformNeutralAssembly = +build_property._SupportedPlatformList = Linux,macOS,Windows +build_property.RootNamespace = cli_args +build_property.ProjectDir = /home/gordon/git/dotnet-tests/cli-args/ diff --git a/cli-args/obj/Debug/net6.0/cli-args.GlobalUsings.g.cs b/cli-args/obj/Debug/net6.0/cli-args.GlobalUsings.g.cs new file mode 100644 index 0000000..8578f3d --- /dev/null +++ b/cli-args/obj/Debug/net6.0/cli-args.GlobalUsings.g.cs @@ -0,0 +1,8 @@ +// +global using global::System; +global using global::System.Collections.Generic; +global using global::System.IO; +global using global::System.Linq; +global using global::System.Net.Http; +global using global::System.Threading; +global using global::System.Threading.Tasks; diff --git a/cli-args/obj/Debug/net6.0/cli-args.assets.cache b/cli-args/obj/Debug/net6.0/cli-args.assets.cache new file mode 100644 index 0000000..3200a48 Binary files /dev/null and b/cli-args/obj/Debug/net6.0/cli-args.assets.cache differ diff --git a/cli-args/obj/Debug/net6.0/cli-args.csproj.AssemblyReference.cache b/cli-args/obj/Debug/net6.0/cli-args.csproj.AssemblyReference.cache new file mode 100644 index 0000000..3defcb8 Binary files /dev/null and b/cli-args/obj/Debug/net6.0/cli-args.csproj.AssemblyReference.cache differ diff --git a/cli-args/obj/Debug/net6.0/cli-args.csproj.CoreCompileInputs.cache b/cli-args/obj/Debug/net6.0/cli-args.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..988b912 --- /dev/null +++ b/cli-args/obj/Debug/net6.0/cli-args.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +5552358914d7d5b0fe79713d56499f99dc42a1f6 diff --git a/cli-args/obj/Debug/net6.0/cli-args.csproj.FileListAbsolute.txt b/cli-args/obj/Debug/net6.0/cli-args.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..efbd43c --- /dev/null +++ b/cli-args/obj/Debug/net6.0/cli-args.csproj.FileListAbsolute.txt @@ -0,0 +1,15 @@ +/home/gordon/git/dotnet-tests/cli-args/obj/Debug/net6.0/cli-args.csproj.AssemblyReference.cache +/home/gordon/git/dotnet-tests/cli-args/obj/Debug/net6.0/cli-args.GeneratedMSBuildEditorConfig.editorconfig +/home/gordon/git/dotnet-tests/cli-args/obj/Debug/net6.0/cli-args.AssemblyInfoInputs.cache +/home/gordon/git/dotnet-tests/cli-args/obj/Debug/net6.0/cli-args.AssemblyInfo.cs +/home/gordon/git/dotnet-tests/cli-args/obj/Debug/net6.0/cli-args.csproj.CoreCompileInputs.cache +/home/gordon/git/dotnet-tests/cli-args/bin/Debug/net6.0/cli-args +/home/gordon/git/dotnet-tests/cli-args/bin/Debug/net6.0/cli-args.deps.json +/home/gordon/git/dotnet-tests/cli-args/bin/Debug/net6.0/cli-args.runtimeconfig.json +/home/gordon/git/dotnet-tests/cli-args/bin/Debug/net6.0/cli-args.dll +/home/gordon/git/dotnet-tests/cli-args/bin/Debug/net6.0/cli-args.pdb +/home/gordon/git/dotnet-tests/cli-args/obj/Debug/net6.0/cli-args.dll +/home/gordon/git/dotnet-tests/cli-args/obj/Debug/net6.0/refint/cli-args.dll +/home/gordon/git/dotnet-tests/cli-args/obj/Debug/net6.0/cli-args.pdb +/home/gordon/git/dotnet-tests/cli-args/obj/Debug/net6.0/cli-args.genruntimeconfig.cache +/home/gordon/git/dotnet-tests/cli-args/obj/Debug/net6.0/ref/cli-args.dll diff --git a/cli-args/obj/Debug/net6.0/cli-args.dll b/cli-args/obj/Debug/net6.0/cli-args.dll new file mode 100644 index 0000000..3a25ef1 Binary files /dev/null and b/cli-args/obj/Debug/net6.0/cli-args.dll differ diff --git a/cli-args/obj/Debug/net6.0/cli-args.genruntimeconfig.cache b/cli-args/obj/Debug/net6.0/cli-args.genruntimeconfig.cache new file mode 100644 index 0000000..d691f24 --- /dev/null +++ b/cli-args/obj/Debug/net6.0/cli-args.genruntimeconfig.cache @@ -0,0 +1 @@ +88240fd2853022da532f77fffab91759b052cbad diff --git a/cli-args/obj/Debug/net6.0/cli-args.pdb b/cli-args/obj/Debug/net6.0/cli-args.pdb new file mode 100644 index 0000000..3283a4e Binary files /dev/null and b/cli-args/obj/Debug/net6.0/cli-args.pdb differ diff --git a/cli-args/obj/Debug/net6.0/ref/cli-args.dll b/cli-args/obj/Debug/net6.0/ref/cli-args.dll new file mode 100644 index 0000000..2d5634d Binary files /dev/null and b/cli-args/obj/Debug/net6.0/ref/cli-args.dll differ diff --git a/cli-args/obj/Debug/net6.0/refint/cli-args.dll b/cli-args/obj/Debug/net6.0/refint/cli-args.dll new file mode 100644 index 0000000..2d5634d Binary files /dev/null and b/cli-args/obj/Debug/net6.0/refint/cli-args.dll differ diff --git a/cli-args/obj/cli-args.csproj.nuget.dgspec.json b/cli-args/obj/cli-args.csproj.nuget.dgspec.json new file mode 100644 index 0000000..705fbc2 --- /dev/null +++ b/cli-args/obj/cli-args.csproj.nuget.dgspec.json @@ -0,0 +1,67 @@ +{ + "format": 1, + "restore": { + "/home/gordon/git/dotnet-tests/cli-args/cli-args.csproj": {} + }, + "projects": { + "/home/gordon/git/dotnet-tests/cli-args/cli-args.csproj": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "/home/gordon/git/dotnet-tests/cli-args/cli-args.csproj", + "projectName": "cli-args", + "projectPath": "/home/gordon/git/dotnet-tests/cli-args/cli-args.csproj", + "packagesPath": "/home/gordon/.nuget/packages/", + "outputPath": "/home/gordon/git/dotnet-tests/cli-args/obj/", + "projectStyle": "PackageReference", + "configFilePaths": [ + "/home/gordon/.nuget/NuGet/NuGet.Config" + ], + "originalTargetFrameworks": [ + "net6.0" + ], + "sources": { + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + } + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48", + "net481" + ], + "assetTargetFallback": true, + "warn": true, + "downloadDependencies": [ + { + "name": "Microsoft.AspNetCore.App.Ref", + "version": "[6.0.9, 6.0.9]" + } + ], + "frameworkReferences": { + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/6.0.401/RuntimeIdentifierGraph.json" + } + } + } + } +} \ No newline at end of file diff --git a/cli-args/obj/cli-args.csproj.nuget.g.props b/cli-args/obj/cli-args.csproj.nuget.g.props new file mode 100644 index 0000000..1889943 --- /dev/null +++ b/cli-args/obj/cli-args.csproj.nuget.g.props @@ -0,0 +1,15 @@ + + + + True + NuGet + $(MSBuildThisFileDirectory)project.assets.json + /home/gordon/.nuget/packages/ + /home/gordon/.nuget/packages/ + PackageReference + 6.3.0 + + + + + \ No newline at end of file diff --git a/cli-args/obj/cli-args.csproj.nuget.g.targets b/cli-args/obj/cli-args.csproj.nuget.g.targets new file mode 100644 index 0000000..3dc06ef --- /dev/null +++ b/cli-args/obj/cli-args.csproj.nuget.g.targets @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/cli-args/obj/project.assets.json b/cli-args/obj/project.assets.json new file mode 100644 index 0000000..bc4fce2 --- /dev/null +++ b/cli-args/obj/project.assets.json @@ -0,0 +1,72 @@ +{ + "version": 3, + "targets": { + "net6.0": {} + }, + "libraries": {}, + "projectFileDependencyGroups": { + "net6.0": [] + }, + "packageFolders": { + "/home/gordon/.nuget/packages/": {} + }, + "project": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "/home/gordon/git/dotnet-tests/cli-args/cli-args.csproj", + "projectName": "cli-args", + "projectPath": "/home/gordon/git/dotnet-tests/cli-args/cli-args.csproj", + "packagesPath": "/home/gordon/.nuget/packages/", + "outputPath": "/home/gordon/git/dotnet-tests/cli-args/obj/", + "projectStyle": "PackageReference", + "configFilePaths": [ + "/home/gordon/.nuget/NuGet/NuGet.Config" + ], + "originalTargetFrameworks": [ + "net6.0" + ], + "sources": { + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + } + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48", + "net481" + ], + "assetTargetFallback": true, + "warn": true, + "downloadDependencies": [ + { + "name": "Microsoft.AspNetCore.App.Ref", + "version": "[6.0.9, 6.0.9]" + } + ], + "frameworkReferences": { + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/6.0.401/RuntimeIdentifierGraph.json" + } + } + } +} \ No newline at end of file diff --git a/cli-args/obj/project.nuget.cache b/cli-args/obj/project.nuget.cache new file mode 100644 index 0000000..28d722d --- /dev/null +++ b/cli-args/obj/project.nuget.cache @@ -0,0 +1,10 @@ +{ + "version": 2, + "dgSpecHash": "VXwvmEpGzLbECp4Qyzgib2vDk6jac91EiD5q4QJWAjeDVVEkPw4dzFyAeEe/762KrL6mhQSKEJ+courypaBOMg==", + "success": true, + "projectFilePath": "/home/gordon/git/dotnet-tests/cli-args/cli-args.csproj", + "expectedPackageFiles": [ + "/home/gordon/.nuget/packages/microsoft.aspnetcore.app.ref/6.0.9/microsoft.aspnetcore.app.ref.6.0.9.nupkg.sha512" + ], + "logs": [] +} \ No newline at end of file diff --git a/client-server/Program.cs b/client-server/Program.cs new file mode 100644 index 0000000..c7228da --- /dev/null +++ b/client-server/Program.cs @@ -0,0 +1,16 @@ +public class Program +{ + public static async Task Main(string[] args) + { + if (args.Contains("--host")) + { + var TcpListener = new TcpServer(); + await TcpListener.Run(); + } + if (args.Contains("--client")) + { + var TcpClient = new TcpClient(); + await TcpClient.Run(); + } + } +} diff --git a/client-server/bin/Debug/net6.0/Newtonsoft.Json.dll b/client-server/bin/Debug/net6.0/Newtonsoft.Json.dll new file mode 100755 index 0000000..1ffeabe Binary files /dev/null and b/client-server/bin/Debug/net6.0/Newtonsoft.Json.dll differ diff --git a/client-server/bin/Debug/net6.0/WatsonTcp.dll b/client-server/bin/Debug/net6.0/WatsonTcp.dll new file mode 100755 index 0000000..4231ce5 Binary files /dev/null and b/client-server/bin/Debug/net6.0/WatsonTcp.dll differ diff --git a/client-server/bin/Debug/net6.0/client-server b/client-server/bin/Debug/net6.0/client-server new file mode 100755 index 0000000..7ca177e Binary files /dev/null and b/client-server/bin/Debug/net6.0/client-server differ diff --git a/client-server/bin/Debug/net6.0/client-server.deps.json b/client-server/bin/Debug/net6.0/client-server.deps.json new file mode 100644 index 0000000..143c703 --- /dev/null +++ b/client-server/bin/Debug/net6.0/client-server.deps.json @@ -0,0 +1,59 @@ +{ + "runtimeTarget": { + "name": ".NETCoreApp,Version=v6.0", + "signature": "" + }, + "compilationOptions": {}, + "targets": { + ".NETCoreApp,Version=v6.0": { + "client-server/1.0.0": { + "dependencies": { + "WatsonTcp": "4.8.14.14" + }, + "runtime": { + "client-server.dll": {} + } + }, + "Newtonsoft.Json/13.0.1": { + "runtime": { + "lib/netstandard2.0/Newtonsoft.Json.dll": { + "assemblyVersion": "13.0.0.0", + "fileVersion": "13.0.1.25517" + } + } + }, + "WatsonTcp/4.8.14.14": { + "dependencies": { + "Newtonsoft.Json": "13.0.1" + }, + "runtime": { + "lib/net6.0/WatsonTcp.dll": { + "assemblyVersion": "4.8.14.14", + "fileVersion": "4.8.14.14" + } + } + } + } + }, + "libraries": { + "client-server/1.0.0": { + "type": "project", + "serviceable": false, + "sha512": "" + }, + "Newtonsoft.Json/13.0.1": { + "type": "package", + "serviceable": true, + "sha512": "sha512-ppPFpBcvxdsfUonNcvITKqLl3bqxWbDCZIzDWHzjpdAHRFfZe0Dw9HmA0+za13IdyrgJwpkDTDA9fHaxOrt20A==", + "path": "newtonsoft.json/13.0.1", + "hashPath": "newtonsoft.json.13.0.1.nupkg.sha512" + }, + "WatsonTcp/4.8.14.14": { + "type": "package", + "serviceable": true, + "sha512": "sha512-ANq8kEqFcyvgxq/CrKJAFwxDS01T0U9t+H4f7WVrRjf0XMw8aaRRd1WQi5lNS/8W9gf9FOUVLHSY0Gfsn6vN6g==", + "path": "watsontcp/4.8.14.14", + "hashPath": "watsontcp.4.8.14.14.nupkg.sha512" + } + } +} \ No newline at end of file diff --git a/client-server/bin/Debug/net6.0/client-server.dll b/client-server/bin/Debug/net6.0/client-server.dll new file mode 100644 index 0000000..22ad808 Binary files /dev/null and b/client-server/bin/Debug/net6.0/client-server.dll differ diff --git a/client-server/bin/Debug/net6.0/client-server.pdb b/client-server/bin/Debug/net6.0/client-server.pdb new file mode 100644 index 0000000..cf05c0b Binary files /dev/null and b/client-server/bin/Debug/net6.0/client-server.pdb differ diff --git a/client-server/bin/Debug/net6.0/client-server.runtimeconfig.json b/client-server/bin/Debug/net6.0/client-server.runtimeconfig.json new file mode 100644 index 0000000..4986d16 --- /dev/null +++ b/client-server/bin/Debug/net6.0/client-server.runtimeconfig.json @@ -0,0 +1,9 @@ +{ + "runtimeOptions": { + "tfm": "net6.0", + "framework": { + "name": "Microsoft.NETCore.App", + "version": "6.0.0" + } + } +} \ No newline at end of file diff --git a/client-server/client-server.csproj b/client-server/client-server.csproj new file mode 100644 index 0000000..555d5df --- /dev/null +++ b/client-server/client-server.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + client_server + enable + enable + + + + + + + diff --git a/client-server/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs b/client-server/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs new file mode 100644 index 0000000..f795be5 --- /dev/null +++ b/client-server/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")] diff --git a/client-server/obj/Debug/net6.0/apphost b/client-server/obj/Debug/net6.0/apphost new file mode 100755 index 0000000..7ca177e Binary files /dev/null and b/client-server/obj/Debug/net6.0/apphost differ diff --git a/client-server/obj/Debug/net6.0/client-server.AssemblyInfo.cs b/client-server/obj/Debug/net6.0/client-server.AssemblyInfo.cs new file mode 100644 index 0000000..4e98425 --- /dev/null +++ b/client-server/obj/Debug/net6.0/client-server.AssemblyInfo.cs @@ -0,0 +1,22 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: System.Reflection.AssemblyCompanyAttribute("client-server")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] +[assembly: System.Reflection.AssemblyProductAttribute("client-server")] +[assembly: System.Reflection.AssemblyTitleAttribute("client-server")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/client-server/obj/Debug/net6.0/client-server.AssemblyInfoInputs.cache b/client-server/obj/Debug/net6.0/client-server.AssemblyInfoInputs.cache new file mode 100644 index 0000000..01206df --- /dev/null +++ b/client-server/obj/Debug/net6.0/client-server.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +c7088ec762d1d64cd13ee1cec0afaa471a0f69d3 diff --git a/client-server/obj/Debug/net6.0/client-server.GeneratedMSBuildEditorConfig.editorconfig b/client-server/obj/Debug/net6.0/client-server.GeneratedMSBuildEditorConfig.editorconfig new file mode 100644 index 0000000..255ade4 --- /dev/null +++ b/client-server/obj/Debug/net6.0/client-server.GeneratedMSBuildEditorConfig.editorconfig @@ -0,0 +1,10 @@ +is_global = true +build_property.TargetFramework = net6.0 +build_property.TargetPlatformMinVersion = +build_property.UsingMicrosoftNETSdkWeb = +build_property.ProjectTypeGuids = +build_property.InvariantGlobalization = +build_property.PlatformNeutralAssembly = +build_property._SupportedPlatformList = Linux,macOS,Windows +build_property.RootNamespace = client_server +build_property.ProjectDir = /home/gordon/git/dotnet-tests/client-server/ diff --git a/client-server/obj/Debug/net6.0/client-server.GlobalUsings.g.cs b/client-server/obj/Debug/net6.0/client-server.GlobalUsings.g.cs new file mode 100644 index 0000000..8578f3d --- /dev/null +++ b/client-server/obj/Debug/net6.0/client-server.GlobalUsings.g.cs @@ -0,0 +1,8 @@ +// +global using global::System; +global using global::System.Collections.Generic; +global using global::System.IO; +global using global::System.Linq; +global using global::System.Net.Http; +global using global::System.Threading; +global using global::System.Threading.Tasks; diff --git a/client-server/obj/Debug/net6.0/client-server.assets.cache b/client-server/obj/Debug/net6.0/client-server.assets.cache new file mode 100644 index 0000000..ae00fea Binary files /dev/null and b/client-server/obj/Debug/net6.0/client-server.assets.cache differ diff --git a/client-server/obj/Debug/net6.0/client-server.csproj.AssemblyReference.cache b/client-server/obj/Debug/net6.0/client-server.csproj.AssemblyReference.cache new file mode 100644 index 0000000..3ee8726 Binary files /dev/null and b/client-server/obj/Debug/net6.0/client-server.csproj.AssemblyReference.cache differ diff --git a/client-server/obj/Debug/net6.0/client-server.csproj.CopyComplete b/client-server/obj/Debug/net6.0/client-server.csproj.CopyComplete new file mode 100644 index 0000000..e69de29 diff --git a/client-server/obj/Debug/net6.0/client-server.csproj.CoreCompileInputs.cache b/client-server/obj/Debug/net6.0/client-server.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..b9e0a96 --- /dev/null +++ b/client-server/obj/Debug/net6.0/client-server.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +c07f56ba41176466d03d79fc9315548334378d3c diff --git a/client-server/obj/Debug/net6.0/client-server.csproj.FileListAbsolute.txt b/client-server/obj/Debug/net6.0/client-server.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..7abad83 --- /dev/null +++ b/client-server/obj/Debug/net6.0/client-server.csproj.FileListAbsolute.txt @@ -0,0 +1,18 @@ +/home/gordon/git/dotnet-tests/client-server/bin/Debug/net6.0/client-server +/home/gordon/git/dotnet-tests/client-server/bin/Debug/net6.0/client-server.deps.json +/home/gordon/git/dotnet-tests/client-server/bin/Debug/net6.0/client-server.runtimeconfig.json +/home/gordon/git/dotnet-tests/client-server/bin/Debug/net6.0/client-server.dll +/home/gordon/git/dotnet-tests/client-server/bin/Debug/net6.0/client-server.pdb +/home/gordon/git/dotnet-tests/client-server/obj/Debug/net6.0/client-server.csproj.AssemblyReference.cache +/home/gordon/git/dotnet-tests/client-server/obj/Debug/net6.0/client-server.GeneratedMSBuildEditorConfig.editorconfig +/home/gordon/git/dotnet-tests/client-server/obj/Debug/net6.0/client-server.AssemblyInfoInputs.cache +/home/gordon/git/dotnet-tests/client-server/obj/Debug/net6.0/client-server.AssemblyInfo.cs +/home/gordon/git/dotnet-tests/client-server/obj/Debug/net6.0/client-server.csproj.CoreCompileInputs.cache +/home/gordon/git/dotnet-tests/client-server/obj/Debug/net6.0/client-server.dll +/home/gordon/git/dotnet-tests/client-server/obj/Debug/net6.0/refint/client-server.dll +/home/gordon/git/dotnet-tests/client-server/obj/Debug/net6.0/client-server.pdb +/home/gordon/git/dotnet-tests/client-server/obj/Debug/net6.0/client-server.genruntimeconfig.cache +/home/gordon/git/dotnet-tests/client-server/obj/Debug/net6.0/ref/client-server.dll +/home/gordon/git/dotnet-tests/client-server/bin/Debug/net6.0/Newtonsoft.Json.dll +/home/gordon/git/dotnet-tests/client-server/bin/Debug/net6.0/WatsonTcp.dll +/home/gordon/git/dotnet-tests/client-server/obj/Debug/net6.0/client-server.csproj.CopyComplete diff --git a/client-server/obj/Debug/net6.0/client-server.dll b/client-server/obj/Debug/net6.0/client-server.dll new file mode 100644 index 0000000..22ad808 Binary files /dev/null and b/client-server/obj/Debug/net6.0/client-server.dll differ diff --git a/client-server/obj/Debug/net6.0/client-server.genruntimeconfig.cache b/client-server/obj/Debug/net6.0/client-server.genruntimeconfig.cache new file mode 100644 index 0000000..70f6e6e --- /dev/null +++ b/client-server/obj/Debug/net6.0/client-server.genruntimeconfig.cache @@ -0,0 +1 @@ +5a54e844328afcd510367ddc9200bbdb96332e01 diff --git a/client-server/obj/Debug/net6.0/client-server.pdb b/client-server/obj/Debug/net6.0/client-server.pdb new file mode 100644 index 0000000..cf05c0b Binary files /dev/null and b/client-server/obj/Debug/net6.0/client-server.pdb differ diff --git a/client-server/obj/Debug/net6.0/ref/client-server.dll b/client-server/obj/Debug/net6.0/ref/client-server.dll new file mode 100644 index 0000000..1c92fdc Binary files /dev/null and b/client-server/obj/Debug/net6.0/ref/client-server.dll differ diff --git a/client-server/obj/Debug/net6.0/refint/client-server.dll b/client-server/obj/Debug/net6.0/refint/client-server.dll new file mode 100644 index 0000000..1c92fdc Binary files /dev/null and b/client-server/obj/Debug/net6.0/refint/client-server.dll differ diff --git a/client-server/obj/client-server.csproj.nuget.dgspec.json b/client-server/obj/client-server.csproj.nuget.dgspec.json new file mode 100644 index 0000000..13bbcae --- /dev/null +++ b/client-server/obj/client-server.csproj.nuget.dgspec.json @@ -0,0 +1,73 @@ +{ + "format": 1, + "restore": { + "/home/gordon/git/dotnet-tests/client-server/client-server.csproj": {} + }, + "projects": { + "/home/gordon/git/dotnet-tests/client-server/client-server.csproj": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "/home/gordon/git/dotnet-tests/client-server/client-server.csproj", + "projectName": "client-server", + "projectPath": "/home/gordon/git/dotnet-tests/client-server/client-server.csproj", + "packagesPath": "/home/gordon/.nuget/packages/", + "outputPath": "/home/gordon/git/dotnet-tests/client-server/obj/", + "projectStyle": "PackageReference", + "configFilePaths": [ + "/home/gordon/.nuget/NuGet/NuGet.Config" + ], + "originalTargetFrameworks": [ + "net6.0" + ], + "sources": { + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + } + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "dependencies": { + "WatsonTcp": { + "target": "Package", + "version": "[4.8.14.14, )" + } + }, + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48", + "net481" + ], + "assetTargetFallback": true, + "warn": true, + "downloadDependencies": [ + { + "name": "Microsoft.AspNetCore.App.Ref", + "version": "[6.0.10, 6.0.10]" + } + ], + "frameworkReferences": { + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/6.0.402/RuntimeIdentifierGraph.json" + } + } + } + } +} \ No newline at end of file diff --git a/client-server/obj/client-server.csproj.nuget.g.props b/client-server/obj/client-server.csproj.nuget.g.props new file mode 100644 index 0000000..41af935 --- /dev/null +++ b/client-server/obj/client-server.csproj.nuget.g.props @@ -0,0 +1,15 @@ + + + + True + NuGet + $(MSBuildThisFileDirectory)project.assets.json + /home/gordon/.nuget/packages/ + /home/gordon/.nuget/packages/ + PackageReference + 6.3.1 + + + + + \ No newline at end of file diff --git a/client-server/obj/client-server.csproj.nuget.g.targets b/client-server/obj/client-server.csproj.nuget.g.targets new file mode 100644 index 0000000..3dc06ef --- /dev/null +++ b/client-server/obj/client-server.csproj.nuget.g.targets @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/client-server/obj/project.assets.json b/client-server/obj/project.assets.json new file mode 100644 index 0000000..9e97ac3 --- /dev/null +++ b/client-server/obj/project.assets.json @@ -0,0 +1,165 @@ +{ + "version": 3, + "targets": { + "net6.0": { + "Newtonsoft.Json/13.0.1": { + "type": "package", + "compile": { + "lib/netstandard2.0/Newtonsoft.Json.dll": { + "related": ".xml" + } + }, + "runtime": { + "lib/netstandard2.0/Newtonsoft.Json.dll": { + "related": ".xml" + } + } + }, + "WatsonTcp/4.8.14.14": { + "type": "package", + "dependencies": { + "Newtonsoft.Json": "13.0.1" + }, + "compile": { + "lib/net6.0/WatsonTcp.dll": { + "related": ".xml" + } + }, + "runtime": { + "lib/net6.0/WatsonTcp.dll": { + "related": ".xml" + } + } + } + } + }, + "libraries": { + "Newtonsoft.Json/13.0.1": { + "sha512": "ppPFpBcvxdsfUonNcvITKqLl3bqxWbDCZIzDWHzjpdAHRFfZe0Dw9HmA0+za13IdyrgJwpkDTDA9fHaxOrt20A==", + "type": "package", + "path": "newtonsoft.json/13.0.1", + "files": [ + ".nupkg.metadata", + ".signature.p7s", + "LICENSE.md", + "lib/net20/Newtonsoft.Json.dll", + "lib/net20/Newtonsoft.Json.xml", + "lib/net35/Newtonsoft.Json.dll", + "lib/net35/Newtonsoft.Json.xml", + "lib/net40/Newtonsoft.Json.dll", + "lib/net40/Newtonsoft.Json.xml", + "lib/net45/Newtonsoft.Json.dll", + "lib/net45/Newtonsoft.Json.xml", + "lib/netstandard1.0/Newtonsoft.Json.dll", + "lib/netstandard1.0/Newtonsoft.Json.xml", + "lib/netstandard1.3/Newtonsoft.Json.dll", + "lib/netstandard1.3/Newtonsoft.Json.xml", + "lib/netstandard2.0/Newtonsoft.Json.dll", + "lib/netstandard2.0/Newtonsoft.Json.xml", + "newtonsoft.json.13.0.1.nupkg.sha512", + "newtonsoft.json.nuspec", + "packageIcon.png" + ] + }, + "WatsonTcp/4.8.14.14": { + "sha512": "ANq8kEqFcyvgxq/CrKJAFwxDS01T0U9t+H4f7WVrRjf0XMw8aaRRd1WQi5lNS/8W9gf9FOUVLHSY0Gfsn6vN6g==", + "type": "package", + "path": "watsontcp/4.8.14.14", + "files": [ + ".nupkg.metadata", + ".signature.p7s", + "LICENSE.md", + "lib/net461/WatsonTcp.dll", + "lib/net461/WatsonTcp.xml", + "lib/net472/WatsonTcp.dll", + "lib/net472/WatsonTcp.xml", + "lib/net5.0/WatsonTcp.dll", + "lib/net5.0/WatsonTcp.xml", + "lib/net6.0/WatsonTcp.dll", + "lib/net6.0/WatsonTcp.xml", + "lib/netcoreapp3.1/WatsonTcp.dll", + "lib/netcoreapp3.1/WatsonTcp.xml", + "lib/netstandard2.0/WatsonTcp.dll", + "lib/netstandard2.0/WatsonTcp.xml", + "lib/netstandard2.1/WatsonTcp.dll", + "lib/netstandard2.1/WatsonTcp.xml", + "watson.png", + "watsontcp.4.8.14.14.nupkg.sha512", + "watsontcp.nuspec" + ] + } + }, + "projectFileDependencyGroups": { + "net6.0": [ + "WatsonTcp >= 4.8.14.14" + ] + }, + "packageFolders": { + "/home/gordon/.nuget/packages/": {} + }, + "project": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "/home/gordon/git/dotnet-tests/client-server/client-server.csproj", + "projectName": "client-server", + "projectPath": "/home/gordon/git/dotnet-tests/client-server/client-server.csproj", + "packagesPath": "/home/gordon/.nuget/packages/", + "outputPath": "/home/gordon/git/dotnet-tests/client-server/obj/", + "projectStyle": "PackageReference", + "configFilePaths": [ + "/home/gordon/.nuget/NuGet/NuGet.Config" + ], + "originalTargetFrameworks": [ + "net6.0" + ], + "sources": { + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + } + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "dependencies": { + "WatsonTcp": { + "target": "Package", + "version": "[4.8.14.14, )" + } + }, + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48", + "net481" + ], + "assetTargetFallback": true, + "warn": true, + "downloadDependencies": [ + { + "name": "Microsoft.AspNetCore.App.Ref", + "version": "[6.0.10, 6.0.10]" + } + ], + "frameworkReferences": { + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/6.0.402/RuntimeIdentifierGraph.json" + } + } + } +} \ No newline at end of file diff --git a/client-server/obj/project.nuget.cache b/client-server/obj/project.nuget.cache new file mode 100644 index 0000000..a49c26f --- /dev/null +++ b/client-server/obj/project.nuget.cache @@ -0,0 +1,12 @@ +{ + "version": 2, + "dgSpecHash": "gHPzrDYiBQaB4R8iWmVFMrYK0Jd+RWwZD6Pdazvg2LzkcJKrAYjAl/Qb9rUWhm0BfEmhD8zhW+R1qS0k9nkWXA==", + "success": true, + "projectFilePath": "/home/gordon/git/dotnet-tests/client-server/client-server.csproj", + "expectedPackageFiles": [ + "/home/gordon/.nuget/packages/newtonsoft.json/13.0.1/newtonsoft.json.13.0.1.nupkg.sha512", + "/home/gordon/.nuget/packages/watsontcp/4.8.14.14/watsontcp.4.8.14.14.nupkg.sha512", + "/home/gordon/.nuget/packages/microsoft.aspnetcore.app.ref/6.0.10/microsoft.aspnetcore.app.ref.6.0.10.nupkg.sha512" + ], + "logs": [] +} \ No newline at end of file diff --git a/client-server/src/TcpClient.cs b/client-server/src/TcpClient.cs new file mode 100644 index 0000000..b870817 --- /dev/null +++ b/client-server/src/TcpClient.cs @@ -0,0 +1,20 @@ +using System.Text; +using WatsonTcp; + +class TcpClient +{ + public async Task Run() + { + var client = new WatsonTcpClient("127.0.0.1", 42069); + client.Events.MessageReceived += this.onMessageReceived; + client.Connect(); + await client.SendAsync("Hello World!"); + await Task.Delay(-1); + } + + private void onMessageReceived(object? sender, MessageReceivedEventArgs args) + { + var messageString = Encoding.UTF8.GetString(args.Data); + Console.WriteLine("Message received: " + messageString); + } +} diff --git a/client-server/src/TcpServer.cs b/client-server/src/TcpServer.cs new file mode 100644 index 0000000..4062e12 --- /dev/null +++ b/client-server/src/TcpServer.cs @@ -0,0 +1,31 @@ +using System.Text; +using WatsonTcp; + +class TcpServer +{ + public async Task Run() + { + var server = new WatsonTcpServer("127.0.0.1", 42069); + server.Events.ClientConnected += this.clientConnected; + server.Events.ClientDisconnected += this.clientDisconnected; + server.Events.MessageReceived += this.messageReceived; + server.Start(); + await Task.Delay(-1); + } + + private void clientConnected(object? sender, ConnectionEventArgs args) + { + Console.WriteLine("Client connected: " + args.IpPort); + } + + private void clientDisconnected(object? sender, DisconnectionEventArgs args) + { + Console.WriteLine("Client disconnected: " + args.IpPort); + } + + private void messageReceived(object? sender, MessageReceivedEventArgs args) + { + var message = Encoding.UTF8.GetString(args.Data); + Console.WriteLine("Message received: " + args.IpPort + " " + message); + } +} diff --git a/di-test/Program.cs b/di-test/Program.cs new file mode 100644 index 0000000..35315f4 --- /dev/null +++ b/di-test/Program.cs @@ -0,0 +1,19 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); +var masterService = new MasterService(); +masterService.Respond(); +var services = new HashSet(); + +services.Add(new ServiceA()); +services.Add(new ServiceB()); + +foreach (var service in services) +{ + var methods = (service.GetType().GetMethods()); + foreach (var method in methods) + { + Console.WriteLine(method.Name); + } + Console.WriteLine("-----"); + service.GetType().GetMethod("Respond")!.Invoke(service, null); +} diff --git a/di-test/bin/Debug/net6.0/di-test b/di-test/bin/Debug/net6.0/di-test new file mode 100755 index 0000000..cb1dd17 Binary files /dev/null and b/di-test/bin/Debug/net6.0/di-test differ diff --git a/di-test/bin/Debug/net6.0/di-test.deps.json b/di-test/bin/Debug/net6.0/di-test.deps.json new file mode 100644 index 0000000..4437b2e --- /dev/null +++ b/di-test/bin/Debug/net6.0/di-test.deps.json @@ -0,0 +1,23 @@ +{ + "runtimeTarget": { + "name": ".NETCoreApp,Version=v6.0", + "signature": "" + }, + "compilationOptions": {}, + "targets": { + ".NETCoreApp,Version=v6.0": { + "di-test/1.0.0": { + "runtime": { + "di-test.dll": {} + } + } + } + }, + "libraries": { + "di-test/1.0.0": { + "type": "project", + "serviceable": false, + "sha512": "" + } + } +} \ No newline at end of file diff --git a/di-test/bin/Debug/net6.0/di-test.dll b/di-test/bin/Debug/net6.0/di-test.dll new file mode 100644 index 0000000..772609a Binary files /dev/null and b/di-test/bin/Debug/net6.0/di-test.dll differ diff --git a/di-test/bin/Debug/net6.0/di-test.pdb b/di-test/bin/Debug/net6.0/di-test.pdb new file mode 100644 index 0000000..4e4fc92 Binary files /dev/null and b/di-test/bin/Debug/net6.0/di-test.pdb differ diff --git a/di-test/bin/Debug/net6.0/di-test.runtimeconfig.json b/di-test/bin/Debug/net6.0/di-test.runtimeconfig.json new file mode 100644 index 0000000..4986d16 --- /dev/null +++ b/di-test/bin/Debug/net6.0/di-test.runtimeconfig.json @@ -0,0 +1,9 @@ +{ + "runtimeOptions": { + "tfm": "net6.0", + "framework": { + "name": "Microsoft.NETCore.App", + "version": "6.0.0" + } + } +} \ No newline at end of file diff --git a/di-test/di-test.csproj b/di-test/di-test.csproj new file mode 100644 index 0000000..2f06f43 --- /dev/null +++ b/di-test/di-test.csproj @@ -0,0 +1,11 @@ + + + + Exe + net6.0 + di_test + enable + enable + + + diff --git a/di-test/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs b/di-test/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs new file mode 100644 index 0000000..f795be5 --- /dev/null +++ b/di-test/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")] diff --git a/di-test/obj/Debug/net6.0/apphost b/di-test/obj/Debug/net6.0/apphost new file mode 100755 index 0000000..cb1dd17 Binary files /dev/null and b/di-test/obj/Debug/net6.0/apphost differ diff --git a/di-test/obj/Debug/net6.0/di-test.AssemblyInfo.cs b/di-test/obj/Debug/net6.0/di-test.AssemblyInfo.cs new file mode 100644 index 0000000..fdc1c82 --- /dev/null +++ b/di-test/obj/Debug/net6.0/di-test.AssemblyInfo.cs @@ -0,0 +1,22 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: System.Reflection.AssemblyCompanyAttribute("di-test")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] +[assembly: System.Reflection.AssemblyProductAttribute("di-test")] +[assembly: System.Reflection.AssemblyTitleAttribute("di-test")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/di-test/obj/Debug/net6.0/di-test.AssemblyInfoInputs.cache b/di-test/obj/Debug/net6.0/di-test.AssemblyInfoInputs.cache new file mode 100644 index 0000000..4090c9d --- /dev/null +++ b/di-test/obj/Debug/net6.0/di-test.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +e073c3bc7a500c748d14b6b4412bf65327b91342 diff --git a/di-test/obj/Debug/net6.0/di-test.GeneratedMSBuildEditorConfig.editorconfig b/di-test/obj/Debug/net6.0/di-test.GeneratedMSBuildEditorConfig.editorconfig new file mode 100644 index 0000000..d93ddc0 --- /dev/null +++ b/di-test/obj/Debug/net6.0/di-test.GeneratedMSBuildEditorConfig.editorconfig @@ -0,0 +1,10 @@ +is_global = true +build_property.TargetFramework = net6.0 +build_property.TargetPlatformMinVersion = +build_property.UsingMicrosoftNETSdkWeb = +build_property.ProjectTypeGuids = +build_property.InvariantGlobalization = +build_property.PlatformNeutralAssembly = +build_property._SupportedPlatformList = Linux,macOS,Windows +build_property.RootNamespace = di_test +build_property.ProjectDir = /home/gordon/git/dotnet-tests/di-test/ diff --git a/di-test/obj/Debug/net6.0/di-test.GlobalUsings.g.cs b/di-test/obj/Debug/net6.0/di-test.GlobalUsings.g.cs new file mode 100644 index 0000000..8578f3d --- /dev/null +++ b/di-test/obj/Debug/net6.0/di-test.GlobalUsings.g.cs @@ -0,0 +1,8 @@ +// +global using global::System; +global using global::System.Collections.Generic; +global using global::System.IO; +global using global::System.Linq; +global using global::System.Net.Http; +global using global::System.Threading; +global using global::System.Threading.Tasks; diff --git a/di-test/obj/Debug/net6.0/di-test.assets.cache b/di-test/obj/Debug/net6.0/di-test.assets.cache new file mode 100644 index 0000000..c66409f Binary files /dev/null and b/di-test/obj/Debug/net6.0/di-test.assets.cache differ diff --git a/di-test/obj/Debug/net6.0/di-test.csproj.AssemblyReference.cache b/di-test/obj/Debug/net6.0/di-test.csproj.AssemblyReference.cache new file mode 100644 index 0000000..3defcb8 Binary files /dev/null and b/di-test/obj/Debug/net6.0/di-test.csproj.AssemblyReference.cache differ diff --git a/di-test/obj/Debug/net6.0/di-test.csproj.CoreCompileInputs.cache b/di-test/obj/Debug/net6.0/di-test.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..0206a8a --- /dev/null +++ b/di-test/obj/Debug/net6.0/di-test.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +6981cdd32c34d4d4f9f364cad21416e5b7d904b2 diff --git a/di-test/obj/Debug/net6.0/di-test.csproj.FileListAbsolute.txt b/di-test/obj/Debug/net6.0/di-test.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..50c64bc --- /dev/null +++ b/di-test/obj/Debug/net6.0/di-test.csproj.FileListAbsolute.txt @@ -0,0 +1,15 @@ +/home/gordon/git/dotnet-tests/di-test/bin/Debug/net6.0/di-test +/home/gordon/git/dotnet-tests/di-test/bin/Debug/net6.0/di-test.deps.json +/home/gordon/git/dotnet-tests/di-test/bin/Debug/net6.0/di-test.runtimeconfig.json +/home/gordon/git/dotnet-tests/di-test/bin/Debug/net6.0/di-test.dll +/home/gordon/git/dotnet-tests/di-test/bin/Debug/net6.0/di-test.pdb +/home/gordon/git/dotnet-tests/di-test/obj/Debug/net6.0/di-test.csproj.AssemblyReference.cache +/home/gordon/git/dotnet-tests/di-test/obj/Debug/net6.0/di-test.GeneratedMSBuildEditorConfig.editorconfig +/home/gordon/git/dotnet-tests/di-test/obj/Debug/net6.0/di-test.AssemblyInfoInputs.cache +/home/gordon/git/dotnet-tests/di-test/obj/Debug/net6.0/di-test.AssemblyInfo.cs +/home/gordon/git/dotnet-tests/di-test/obj/Debug/net6.0/di-test.csproj.CoreCompileInputs.cache +/home/gordon/git/dotnet-tests/di-test/obj/Debug/net6.0/di-test.dll +/home/gordon/git/dotnet-tests/di-test/obj/Debug/net6.0/refint/di-test.dll +/home/gordon/git/dotnet-tests/di-test/obj/Debug/net6.0/di-test.pdb +/home/gordon/git/dotnet-tests/di-test/obj/Debug/net6.0/di-test.genruntimeconfig.cache +/home/gordon/git/dotnet-tests/di-test/obj/Debug/net6.0/ref/di-test.dll diff --git a/di-test/obj/Debug/net6.0/di-test.dll b/di-test/obj/Debug/net6.0/di-test.dll new file mode 100644 index 0000000..772609a Binary files /dev/null and b/di-test/obj/Debug/net6.0/di-test.dll differ diff --git a/di-test/obj/Debug/net6.0/di-test.genruntimeconfig.cache b/di-test/obj/Debug/net6.0/di-test.genruntimeconfig.cache new file mode 100644 index 0000000..7b6b321 --- /dev/null +++ b/di-test/obj/Debug/net6.0/di-test.genruntimeconfig.cache @@ -0,0 +1 @@ +31ea1265b9949672b10fa99cd85c3c7ee96f2b35 diff --git a/di-test/obj/Debug/net6.0/di-test.pdb b/di-test/obj/Debug/net6.0/di-test.pdb new file mode 100644 index 0000000..4e4fc92 Binary files /dev/null and b/di-test/obj/Debug/net6.0/di-test.pdb differ diff --git a/di-test/obj/Debug/net6.0/ref/di-test.dll b/di-test/obj/Debug/net6.0/ref/di-test.dll new file mode 100644 index 0000000..1622aa2 Binary files /dev/null and b/di-test/obj/Debug/net6.0/ref/di-test.dll differ diff --git a/di-test/obj/Debug/net6.0/refint/di-test.dll b/di-test/obj/Debug/net6.0/refint/di-test.dll new file mode 100644 index 0000000..1622aa2 Binary files /dev/null and b/di-test/obj/Debug/net6.0/refint/di-test.dll differ diff --git a/di-test/obj/di-test.csproj.nuget.dgspec.json b/di-test/obj/di-test.csproj.nuget.dgspec.json new file mode 100644 index 0000000..5480e42 --- /dev/null +++ b/di-test/obj/di-test.csproj.nuget.dgspec.json @@ -0,0 +1,67 @@ +{ + "format": 1, + "restore": { + "/home/gordon/git/dotnet-tests/di-test/di-test.csproj": {} + }, + "projects": { + "/home/gordon/git/dotnet-tests/di-test/di-test.csproj": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "/home/gordon/git/dotnet-tests/di-test/di-test.csproj", + "projectName": "di-test", + "projectPath": "/home/gordon/git/dotnet-tests/di-test/di-test.csproj", + "packagesPath": "/home/gordon/.nuget/packages/", + "outputPath": "/home/gordon/git/dotnet-tests/di-test/obj/", + "projectStyle": "PackageReference", + "configFilePaths": [ + "/home/gordon/.nuget/NuGet/NuGet.Config" + ], + "originalTargetFrameworks": [ + "net6.0" + ], + "sources": { + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + } + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48", + "net481" + ], + "assetTargetFallback": true, + "warn": true, + "downloadDependencies": [ + { + "name": "Microsoft.AspNetCore.App.Ref", + "version": "[6.0.9, 6.0.9]" + } + ], + "frameworkReferences": { + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/6.0.401/RuntimeIdentifierGraph.json" + } + } + } + } +} \ No newline at end of file diff --git a/di-test/obj/di-test.csproj.nuget.g.props b/di-test/obj/di-test.csproj.nuget.g.props new file mode 100644 index 0000000..1889943 --- /dev/null +++ b/di-test/obj/di-test.csproj.nuget.g.props @@ -0,0 +1,15 @@ + + + + True + NuGet + $(MSBuildThisFileDirectory)project.assets.json + /home/gordon/.nuget/packages/ + /home/gordon/.nuget/packages/ + PackageReference + 6.3.0 + + + + + \ No newline at end of file diff --git a/di-test/obj/di-test.csproj.nuget.g.targets b/di-test/obj/di-test.csproj.nuget.g.targets new file mode 100644 index 0000000..3dc06ef --- /dev/null +++ b/di-test/obj/di-test.csproj.nuget.g.targets @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/di-test/obj/project.assets.json b/di-test/obj/project.assets.json new file mode 100644 index 0000000..2a5b1a2 --- /dev/null +++ b/di-test/obj/project.assets.json @@ -0,0 +1,72 @@ +{ + "version": 3, + "targets": { + "net6.0": {} + }, + "libraries": {}, + "projectFileDependencyGroups": { + "net6.0": [] + }, + "packageFolders": { + "/home/gordon/.nuget/packages/": {} + }, + "project": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "/home/gordon/git/dotnet-tests/di-test/di-test.csproj", + "projectName": "di-test", + "projectPath": "/home/gordon/git/dotnet-tests/di-test/di-test.csproj", + "packagesPath": "/home/gordon/.nuget/packages/", + "outputPath": "/home/gordon/git/dotnet-tests/di-test/obj/", + "projectStyle": "PackageReference", + "configFilePaths": [ + "/home/gordon/.nuget/NuGet/NuGet.Config" + ], + "originalTargetFrameworks": [ + "net6.0" + ], + "sources": { + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + } + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48", + "net481" + ], + "assetTargetFallback": true, + "warn": true, + "downloadDependencies": [ + { + "name": "Microsoft.AspNetCore.App.Ref", + "version": "[6.0.9, 6.0.9]" + } + ], + "frameworkReferences": { + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/6.0.401/RuntimeIdentifierGraph.json" + } + } + } +} \ No newline at end of file diff --git a/di-test/obj/project.nuget.cache b/di-test/obj/project.nuget.cache new file mode 100644 index 0000000..f0d1a9d --- /dev/null +++ b/di-test/obj/project.nuget.cache @@ -0,0 +1,10 @@ +{ + "version": 2, + "dgSpecHash": "7NHExEg7gnx6R8MGXPXmjVNJ7bBV6o7/ybDYcNxzrpe9wAvd51IQTKzGo/4pqbpByhgnspCoJOnprIF51bmQ+w==", + "success": true, + "projectFilePath": "/home/gordon/git/dotnet-tests/di-test/di-test.csproj", + "expectedPackageFiles": [ + "/home/gordon/.nuget/packages/microsoft.aspnetcore.app.ref/6.0.9/microsoft.aspnetcore.app.ref.6.0.9.nupkg.sha512" + ], + "logs": [] +} \ No newline at end of file diff --git a/di-test/src/MasterService.cs b/di-test/src/MasterService.cs new file mode 100644 index 0000000..a6fbb5c --- /dev/null +++ b/di-test/src/MasterService.cs @@ -0,0 +1,19 @@ +class MasterService : Service +{ + private List services = new List(); + + public MasterService() + { + typeof(MasterService).Assembly.GetTypes() + .Where(t => t.GetCustomAttributes(typeof(ServiceAttribute), false).Length > 0) + // .Where(t => t.IsSubclassOf(typeof(Service))) + .ToList() + .ForEach(t => services.Add((Service)Activator.CreateInstance(t)!)); + } + + public void Respond() + { + Console.WriteLine($"Servic Count: {services.Count}"); + services.ForEach(s => s.Respond()); + } +} diff --git a/di-test/src/ServiceA.cs b/di-test/src/ServiceA.cs new file mode 100644 index 0000000..602de18 --- /dev/null +++ b/di-test/src/ServiceA.cs @@ -0,0 +1,8 @@ +[ServiceAttribute] +class ServiceA : Service +{ + public void Respond() + { + Console.WriteLine("ServiceA"); + } +} diff --git a/di-test/src/ServiceAttribute.cs b/di-test/src/ServiceAttribute.cs new file mode 100644 index 0000000..e7a0099 --- /dev/null +++ b/di-test/src/ServiceAttribute.cs @@ -0,0 +1,7 @@ +[AttributeUsage(AttributeTargets.Class)] +class ServiceAttribute : Attribute +{ + public ServiceAttribute() + { + } +} diff --git a/di-test/src/ServiceB.cs b/di-test/src/ServiceB.cs new file mode 100644 index 0000000..c8d42d8 --- /dev/null +++ b/di-test/src/ServiceB.cs @@ -0,0 +1,8 @@ +[ServiceAttribute] +class ServiceB : Service +{ + public void Respond() + { + Console.WriteLine("ServiceB"); + } +} diff --git a/di-test/src/interface/Service.cs b/di-test/src/interface/Service.cs new file mode 100644 index 0000000..30e0a72 --- /dev/null +++ b/di-test/src/interface/Service.cs @@ -0,0 +1,4 @@ +interface Service +{ + public void Respond(); +}