Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/upgrade settings view to mvvm framework #96

Merged
merged 14 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.ico filter=lfs diff=lfs merge=lfs -text
18 changes: 2 additions & 16 deletions .github/workflows/CheckPullRequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,14 @@ name: Check pull request
on: [pull_request]

jobs:
checkWinFormsBuild:
name: Check windows forms build
runs-on: windows-latest
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Install nuget
uses: nuget/setup-nuget@v1
- name: Nuget restore
run: nuget restore
shell: powershell
- name: Setup msbuild
uses: microsoft/[email protected]
- name: Build project
run: msbuild .\src\XmlFormatter\XmlFormatter.csproj /t:Build /p:Configuration=Release
shell: powershell
checkAvaloniaBuild:
name: Check Avalonia build
runs-on: windows-latest
steps:
- name: Clone repository
uses: actions/checkout@v2
with:
lfs: true
- name: Restore
run: dotnet restore
shell: powershell
Expand Down
93 changes: 7 additions & 86 deletions .github/workflows/CreateLiveBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,14 @@ on:
- '*.*.*'

jobs:
createWinFormsBuild:
name: Create Windows forms build
runs-on: windows-latest
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Get release tag
run: echo "RELEASE_VERSION=$(($env:GITHUB_REF -split '/')[-1] -replace ' ','')" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- name: Check release version
run: echo ${{ env.RELEASE_VERSION }}
- name: Install nuget
uses: nuget/setup-nuget@v1
- name: Nuget restore
run: nuget restore
shell: powershell
- name: Setup msbuild
uses: microsoft/[email protected]
- name: Prepare version
run: echo ${{ env.RELEASE_VERSION }} | Out-File -FilePath .\src\XmlFormatter\Version.txt -Encoding utf8
- name: Check version file
run: Get-Content -Path .\src\XmlFormatter\Version.txt
- name: Build project
run: |
msbuild .\src\XmlFormatter\XmlFormatter.csproj /t:Build /p:Configuration=Release
msbuild .\src\JsonPlugin\JsonPlugin.csproj /t:Build /p:Configuration=Release
msbuild .\src\CorePlugin\CorePlugin.csproj /t:Build /p:Configuration=Release
shell: powershell
- name: Move artifact files
run: |
mkdir upload-artifacts\
mkdir plugins\
mv .\src\CorePlugin\bin\Release\netstandard2.0\CorePlugin.dll plugins\
mv .\src\JsonPlugin\bin\Release\netstandard2.0\JsonPlugin.dll plugins\
mv .\src\JsonPlugin\bin\Release\netstandard2.0\Newtonsoft.Json.dll plugins\
mv .\src\XmlFormatter\bin\Release\** upload-artifacts\
mv LICENSE upload-artifacts\
mv README.md upload-artifacts\
- name: Upload build artifact
uses: actions/upload-artifact@v2
with:
name: WinFormBuildArtifact
path: |
upload-artifacts/
plugins/
createAvaloniaBuildWindows:
name: Create Avalonia build for Windows
runs-on: windows-latest
steps:
- name: Clone repository
uses: actions/checkout@v2
with:
lfs: true
- name: Get release tag
run: echo "RELEASE_VERSION=$(($env:GITHUB_REF -split '/')[-1] -replace ' ','')" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- name: Check release version
Expand Down Expand Up @@ -93,6 +51,8 @@ jobs:
steps:
- name: Clone repository
uses: actions/checkout@v2
with:
lfs: true
- name: Get release tag
run: echo "RELEASE_VERSION=$(($env:GITHUB_REF -split '/')[-1] -replace ' ','')" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- name: Check release version
Expand Down Expand Up @@ -130,6 +90,8 @@ jobs:
steps:
- name: Clone repository
uses: actions/checkout@v2
with:
lfs: true
- name: Get release tag
run: echo "RELEASE_VERSION=$(($env:GITHUB_REF -split '/')[-1] -replace ' ','')" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- name: Check release version
Expand Down Expand Up @@ -161,37 +123,6 @@ jobs:
path: |
upload-artifacts/
plugins/
createWinFormsZip:
name: Create WinForm zip
needs: ["createWinFormsBuild"]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: WinFormBuildArtifact
path: dist
- name: Prepare Formatter
run: |
mkdir dist/upload-artifacts/Plugins
mv dist/plugins/CorePlugin.dll dist/upload-artifacts/Plugins
- name: Create zips
run: |
cd dist/upload-artifacts
zip -r LatestDevelopment_WinFormsXmlFormatter.zip .
cd ../plugins/
zip -r LatestDevelopment_WinFormsJsonPlugin.zip .
- name: Move artifact
run: |
mkdir upload-artifacts/
mv dist/upload-artifacts/LatestDevelopment_WinFormsXmlFormatter.zip upload-artifacts/
mv dist/plugins/LatestDevelopment_WinFormsJsonPlugin.zip upload-artifacts/
- name: Upload WinForms build artifact
uses: actions/upload-artifact@v2
with:
name: WinFormZipArtifact
path: |
upload-artifacts/
createAvaloniaZipWindows:
name: Create Avalonia Windows zip
needs: ["createAvaloniaBuildWindows"]
Expand Down Expand Up @@ -287,7 +218,7 @@ jobs:
upload-artifacts/
uploadRelease:
name: Upload releases
needs: ["createWinFormsZip", "createAvaloniaZipWindows", "createAvaloniaZipLinux", "createAvaloniaZipDarwin"]
needs: ["createAvaloniaZipWindows", "createAvaloniaZipLinux", "createAvaloniaZipDarwin"]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
Expand All @@ -309,16 +240,6 @@ jobs:
body: You cannot update this version from within the application!
draft: true
prerelease: true
- name: Upload WinForm XmlFormatter zip
id: upload-win-form-formatter-zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/WinFormZipArtifact/LatestDevelopment_WinFormsXmlFormatter.zip
asset_name: LatestDevelopment_WinFormsXmlFormatter.zip
asset_content_type: application/zip
- name: Upload WinForm JsonPlugin zip
id: upload-win-form-json-plugin-zip
uses: actions/upload-release-asset@v1
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/LatestBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
steps:
- name: Clone repository
uses: actions/checkout@v2
with:
lfs: true
- name: Install nuget
uses: nuget/setup-nuget@v1
- name: Nuget restore
Expand Down Expand Up @@ -53,6 +55,8 @@ jobs:
steps:
- name: Clone repository
uses: actions/checkout@v2
with:
lfs: true
- name: Build project
run: |
dotnet publish .\src\XmlFormatterOsIndependent\ -c Release -r win-x64 --self-contained true
Expand Down Expand Up @@ -82,6 +86,8 @@ jobs:
steps:
- name: Clone repository
uses: actions/checkout@v2
with:
lfs: true
- name: Build project
run: |
dotnet publish .\src\XmlFormatterOsIndependent\ -c Release -r linux-x64 --self-contained true
Expand Down Expand Up @@ -111,6 +117,8 @@ jobs:
steps:
- name: Clone repository
uses: actions/checkout@v2
with:
lfs: true
- name: Build project
run: |
dotnet publish .\src\XmlFormatterOsIndependent\ -c Release -r osx-x64 --self-contained true
Expand Down Expand Up @@ -266,6 +274,7 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ${{ env.REF_CHECKOUT_BRANCH }}
lfs: true
- name: Download artifacts
uses: actions/download-artifact@v2
with:
Expand Down
6 changes: 0 additions & 6 deletions XmlFormatter.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33414.496
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XmlFormatter", "src\XmlFormatter\XmlFormatter.csproj", "{0EAED5C3-DAB2-4919-9C26-EAD4D8222BD0}"
ProjectSection(ProjectDependencies) = postProject
{4FC9F80F-73AB-4647-8A7D-0F6284CD9258} = {4FC9F80F-73AB-4647-8A7D-0F6284CD9258}
{CF65B491-2BA5-4F7A-968F-35E21DE5CC7D} = {CF65B491-2BA5-4F7A-968F-35E21DE5CC7D}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XmlFormatterModel", "src\XMLFormatterModel\XmlFormatterModel.csproj", "{F2245AAE-DFAF-41CC-8AF2-D3836B558847}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonPlugin", "src\JsonPlugin\JsonPlugin.csproj", "{CF65B491-2BA5-4F7A-968F-35E21DE5CC7D}"
Expand Down
7 changes: 6 additions & 1 deletion src/CorePlugin/CorePlugin.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand All @@ -18,4 +19,8 @@
<ProjectReference Include="..\PluginFramework\PluginFramework.csproj" />
</ItemGroup>

<Target Condition="'$(Configuration)' == 'Debug'" Name="CopyAfterBuild" AfterTargets="Build">
<Copy SourceFiles="$(OutDir)CorePlugin.dll" DestinationFolder="$(ProjectDir)../XmlFormatterOsIndependent/bin/$(Configuration)/$(TargetFramework)/$(PlatformShortName)/plugins" SkipUnchangedFiles="false" />
</Target>

</Project>
21 changes: 10 additions & 11 deletions src/JsonPlugin/JsonFormatter.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Newtonsoft.Json;
using PluginFramework.DataContainer;
using PluginFramework.DataContainer;
using PluginFramework.Formatter;
using System;
using System.IO;
using System.Text.Json;
using System.Threading.Tasks;

namespace JsonPlugin
Expand Down Expand Up @@ -34,14 +34,14 @@ public JsonFormatter()
/// <inheritdoc/>
public override bool ConvertToFlat(string filePath, string outputName)
{
FormatFile(filePath, outputName, Formatting.None);
FormatFile(filePath, outputName, false);
return true;
}

/// <inheritdoc/>
public override bool ConvertToFormatted(string filePath, string outputName)
{
FormatFile(filePath, outputName, Formatting.Indented);
FormatFile(filePath, outputName, true);
return true;
}

Expand All @@ -51,7 +51,7 @@ public override bool ConvertToFormatted(string filePath, string outputName)
/// <param name="inputFilePath">The input file to convert</param>
/// <param name="outputName">The output file to generate</param>
/// <param name="options">The save options to use</param>
private async void FormatFile(string inputFilePath, string outputName, Formatting formatting)
private async void FormatFile(string inputFilePath, string outputName, bool indent)
{
if (!IsFileReadableWriteable(inputFilePath, outputName))
{
Expand All @@ -60,13 +60,12 @@ private async void FormatFile(string inputFilePath, string outputName, Formattin
}

FireEvent("Loading", "Loading ...");
object data = await Task<object>.Run(() =>
dynamic? data = await Task.Run(() =>
{
object returnData = null;
dynamic? returnData = null;
try
{

returnData = JsonConvert.DeserializeObject(File.ReadAllText(inputFilePath));
returnData = JsonSerializer.Deserialize<dynamic>(File.ReadAllText(inputFilePath));
}
catch (Exception)
{
Expand All @@ -76,7 +75,7 @@ private async void FormatFile(string inputFilePath, string outputName, Formattin
return returnData;
});

if (data == null)
if (data is null)
{
return;
}
Expand All @@ -86,7 +85,7 @@ private async void FormatFile(string inputFilePath, string outputName, Formattin
{
try
{
string writeableData = JsonConvert.SerializeObject(data, formatting);
string writeableData = JsonSerializer.Serialize(data, new JsonSerializerOptions { WriteIndented = indent });
File.WriteAllText(outputName, writeableData);
return true;
}
Expand Down
11 changes: 6 additions & 5 deletions src/JsonPlugin/JsonPlugin.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand All @@ -13,12 +14,12 @@
<EmbeddedResource Include="Resources\Description.md" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\PluginFramework\PluginFramework.csproj" />
</ItemGroup>

<Target Condition="'$(Configuration)' == 'Debug'" Name="CopyAfterBuild" AfterTargets="Build">
<Copy SourceFiles="$(OutDir)JsonPlugin.dll" DestinationFolder="$(ProjectDir)../XmlFormatterOsIndependent/bin/$(Configuration)/$(TargetFramework)/$(PlatformShortName)/plugins" SkipUnchangedFiles="false" />
</Target>

</Project>
2 changes: 1 addition & 1 deletion src/PluginFramework/PluginFramework.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/XMLFormatterModel/XmlFormatterModel.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>XmlFormatterModel</AssemblyName>
</PropertyGroup>

Expand Down
Loading