Skip to content

Commit

Permalink
Merge pull request #6 from AaronSaikovski/v2.0.0_big_refactor
Browse files Browse the repository at this point in the history
V2.0.0 big refactor
  • Loading branch information
AaronSaikovski authored Apr 4, 2024
2 parents 25ba0e5 + 8b5786b commit d7810de
Show file tree
Hide file tree
Showing 95 changed files with 947 additions and 819 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: .NET

on:
push:
branches: [ "main" ]
# pull_request:
# branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
# - name: Test
# run: dotnet test --no-build --verbosity normal
13 changes: 0 additions & 13 deletions .idea/.idea.CyberPuzzles/.idea/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions .idea/.idea.CyberPuzzles/.idea/encodings.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/.idea.CyberPuzzles/.idea/indexLayout.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/.idea.CyberPuzzles/.idea/vcs.xml

This file was deleted.

13 changes: 8 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# Cyberpuzzles Crossword - CHANGELOG

## v1.0.0 (2023-12-07)
- Initial v1.0 release for feedback

## v1.0.1 2023-12-07)
- Initial v1.0 release for feedback
- Added serilog logging to both API and main crossword
- refactored solution structure and namespace cleanup to make it more in line with CLEAN & SOLID principles
- fixed async API call
- Merged parser back into main project and deleted the old parser project
- modified parser to use better class instantiation methods for better memory management
- added newer labels to listboxes

## v1.0.2 2023-12-20)
- Fixed list box headers
- Refactored and performance improvements.
- Refactored and performance improvements.

## v1.0.0-Beta2 2024-04-05)

- Major solution and project restructure to follow a more Clean architecture and easier to follow decoupled object hierarchy.
- Refactored for performance and better memory usage.
-
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;

using Crossword.Shared.Config;
using Crossword.Shared.Logger;
using Crossword.Shared.Constants;

namespace Crossword.FetchData;
namespace Crossword.Data;

/// <summary>
/// Fetches data from the Data API
Expand Down Expand Up @@ -36,7 +33,6 @@ public partial class FetchCrosswordData
//pass in the API key to the header
client.DefaultRequestHeaders.Clear();
client.DefaultRequestHeaders.Add(ApiConstants.ApiKeyName, apiKey);
//client.DefaultRequestHeaders.Add(APIConstants.ApiKeyName, apiKey);

//catch inner HttpRequestException
try
Expand All @@ -52,8 +48,6 @@ public partial class FetchCrosswordData
else
{
throw new Exception($"Failed to call the API. Status code: {response.StatusCode}");
//Console.WriteLine($"Failed to call the API. Status code: {response.StatusCode}");
return string.Empty;
}

}
Expand All @@ -64,7 +58,6 @@ public partial class FetchCrosswordData
throw;
}
}

catch (Exception ex)
{
logger.LogError(ex, ex.Message);
Expand Down
13 changes: 13 additions & 0 deletions Crossword.Data/Crossword.Data.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Crossword.Shared\Crossword.Shared.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System;
using System.Threading.Tasks;
using Crossword.Constants;

using Crossword.Shared.Constants;
using Crossword.Shared.Logger;
using Crossword.Shared.Config;

namespace Crossword.FetchData;
namespace Crossword.Data;


public partial class FetchCrosswordData
Expand All @@ -25,11 +24,6 @@ public partial class FetchCrosswordData
{
logger.LogInformation("Start GetCrosswordDataAsync()");

// //Call the API to get the puzzledata....otherwise use default values
// try
// {
//logger.LogInformation("Start GetCrosswordDataAsync()");

//call the API
var apiResponse = await CallDataApiAsync();

Expand All @@ -43,8 +37,7 @@ public partial class FetchCrosswordData
}
finally
{

logger.Dispose();
logger.Dispose();
}
}

Expand Down
10 changes: 10 additions & 0 deletions Crossword.Entities/Crossword.Entities.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>Crosssword.Entities</RootNamespace>
</PropertyGroup>

</Project>
File renamed without changes.
File renamed without changes.
58 changes: 58 additions & 0 deletions Crossword.Net.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Crossword.API", "Crossword.API\Crossword.API.csproj", "{B53EE5F7-E852-47C0-814E-6E559D43A774}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Crossword", "Crossword\Crossword.csproj", "{0BFDE744-5BB3-486D-B194-5826B551CE3F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Crossword.Shared", "Crossword.Shared\Crossword.Shared.csproj", "{8061C3BE-083E-415C-B678-394F8EBCCFC6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Crossword.Parser", "Crossword.Parser\Crossword.Parser.csproj", "{2FE9007A-7C46-48AD-86A5-FCADA1AA2D34}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Crossword.Entities", "Crossword.Entities\Crossword.Entities.csproj", "{629F5D51-C8E0-4C64-BE84-48C5DB565FA8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Crossword.Data", "Crossword.Data\Crossword.Data.csproj", "{08FAF8BC-DBEA-4FCF-9BF9-B2B3E8FD1122}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Crossword.Puzzle", "Crossword.Puzzle\Crossword.Puzzle.csproj", "{96B22047-3AAC-44ED-B501-DD8894083A3C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Crossword.UI", "Crossword.UI\Crossword.UI.csproj", "{81CBCB4A-2F37-42DF-B001-6E5EEFBC1C14}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B53EE5F7-E852-47C0-814E-6E559D43A774}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B53EE5F7-E852-47C0-814E-6E559D43A774}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B53EE5F7-E852-47C0-814E-6E559D43A774}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B53EE5F7-E852-47C0-814E-6E559D43A774}.Release|Any CPU.Build.0 = Release|Any CPU
{0BFDE744-5BB3-486D-B194-5826B551CE3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0BFDE744-5BB3-486D-B194-5826B551CE3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0BFDE744-5BB3-486D-B194-5826B551CE3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0BFDE744-5BB3-486D-B194-5826B551CE3F}.Release|Any CPU.Build.0 = Release|Any CPU
{8061C3BE-083E-415C-B678-394F8EBCCFC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8061C3BE-083E-415C-B678-394F8EBCCFC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8061C3BE-083E-415C-B678-394F8EBCCFC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8061C3BE-083E-415C-B678-394F8EBCCFC6}.Release|Any CPU.Build.0 = Release|Any CPU
{2FE9007A-7C46-48AD-86A5-FCADA1AA2D34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2FE9007A-7C46-48AD-86A5-FCADA1AA2D34}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2FE9007A-7C46-48AD-86A5-FCADA1AA2D34}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2FE9007A-7C46-48AD-86A5-FCADA1AA2D34}.Release|Any CPU.Build.0 = Release|Any CPU
{629F5D51-C8E0-4C64-BE84-48C5DB565FA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{629F5D51-C8E0-4C64-BE84-48C5DB565FA8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{629F5D51-C8E0-4C64-BE84-48C5DB565FA8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{629F5D51-C8E0-4C64-BE84-48C5DB565FA8}.Release|Any CPU.Build.0 = Release|Any CPU
{08FAF8BC-DBEA-4FCF-9BF9-B2B3E8FD1122}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{08FAF8BC-DBEA-4FCF-9BF9-B2B3E8FD1122}.Debug|Any CPU.Build.0 = Debug|Any CPU
{08FAF8BC-DBEA-4FCF-9BF9-B2B3E8FD1122}.Release|Any CPU.ActiveCfg = Release|Any CPU
{08FAF8BC-DBEA-4FCF-9BF9-B2B3E8FD1122}.Release|Any CPU.Build.0 = Release|Any CPU
{96B22047-3AAC-44ED-B501-DD8894083A3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{96B22047-3AAC-44ED-B501-DD8894083A3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{96B22047-3AAC-44ED-B501-DD8894083A3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{96B22047-3AAC-44ED-B501-DD8894083A3C}.Release|Any CPU.Build.0 = Release|Any CPU
{81CBCB4A-2F37-42DF-B001-6E5EEFBC1C14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{81CBCB4A-2F37-42DF-B001-6E5EEFBC1C14}.Debug|Any CPU.Build.0 = Debug|Any CPU
{81CBCB4A-2F37-42DF-B001-6E5EEFBC1C14}.Release|Any CPU.ActiveCfg = Release|Any CPU
{81CBCB4A-2F37-42DF-B001-6E5EEFBC1C14}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
14 changes: 14 additions & 0 deletions Crossword.Parser/Crossword.Parser.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Crossword.Entities\Crossword.Entities.csproj" />
<ProjectReference Include="..\Crossword.Shared\Crossword.Shared.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;

namespace Crossword.Parsers;
namespace Crossword.Parser;

public sealed partial class CrosswordParser
{
Expand All @@ -13,12 +13,7 @@ private void GetAnswers(IReadOnlyList<string> strData)
{
var puzzletempstr = strData[5];
var answertemp = puzzletempstr.Split("#");
//string[] answertemp;

// var puzzletempstr = strData[5];
// answertemp = puzzletempstr.Split("#");
if (_crosswordData == null) return;

_crosswordData.Answers = new string[_crosswordData.NumQuestions];
for (var k = 0; k < _crosswordData.NumQuestions; k++)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;

namespace Crossword.Parsers;
namespace Crossword.Parser;

public sealed partial class CrosswordParser
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;

namespace Crossword.Parsers;
namespace Crossword.Parser;

public sealed partial class CrosswordParser
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;

namespace Crossword.Parsers;
namespace Crossword.Parser;

public sealed partial class CrosswordParser
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;

namespace Crossword.Parsers;
namespace Crossword.Parser;

public sealed partial class CrosswordParser
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Collections.Generic;
using Crossword.Shared.ParserUtils;

namespace Crossword.Parsers;
namespace Crossword.Parser;

public sealed partial class CrosswordParser
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;

namespace Crossword.Parsers;
namespace Crossword.Parser;

public sealed partial class CrosswordParser
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;

namespace Crossword.Parsers;
namespace Crossword.Parser;

public sealed partial class CrosswordParser
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;

namespace Crossword.Parsers;
namespace Crossword.Parser;

public sealed partial class CrosswordParser
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using Crossword.Entities;
namespace Crossword.Parsers;
using Crossword.Entities;

Check warning on line 3 in Crossword.Parser/ParseCrosswordData.cs

View workflow job for this annotation

GitHub Actions / build

The using directive for 'Crossword.Entities' appeared previously in this namespace

Check warning on line 3 in Crossword.Parser/ParseCrosswordData.cs

View workflow job for this annotation

GitHub Actions / build

The using directive for 'Crossword.Entities' appeared previously in this namespace
namespace Crossword.Parser;

public sealed partial class CrosswordParser
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Threading.Tasks;

namespace Crossword.ClueAnswerMap;
namespace Crossword.Puzzle.ClueAnswerMap;

public sealed partial class ClueAnswer
{
Expand All @@ -23,21 +23,13 @@ public bool CheckHint(char hintLetter)
var szAnswerLength = Answer.Length;

//Parallel for loop
// Parallel.For(0, szAnswerLength, i =>
// {
// if (SqAnswerSquares is null || Answer[i] != hintLetter ||
// SqAnswerSquares[i]!.Letter == hintLetter) return;
// SqAnswerSquares[i]?.SetLetter(hintLetter, IsAcross);
// foundResult = true;
// });

for (var i=0;i<szAnswerLength;i++)
Parallel.For(0, szAnswerLength, i =>
{
if (SqAnswerSquares is null || Answer[i] != hintLetter ||
SqAnswerSquares[i]!.Letter == hintLetter) break;
SqAnswerSquares[i]!.Letter == hintLetter) return;
SqAnswerSquares[i]?.SetLetter(hintLetter, IsAcross);
foundResult = true;
}
});

return foundResult;
}
Expand Down
Loading

0 comments on commit d7810de

Please sign in to comment.