Skip to content
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
32 changes: 9 additions & 23 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,24 @@ jobs:
name: Analyze
runs-on: windows-latest

strategy:
fail-fast: false
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ['csharp']
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0'
dotnet-version: '9.0'

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
languages: csharp
build-mode: none

- name: Build L10n
run: |
dotnet restore
dotnet build
- name: Autobuild
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FakeItEasy" Version="8.1.0" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="FakeItEasy" Version="8.3.0" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.5" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.13.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion MN.L10n.Analyzer/MN.L10n.Analyzer/MN.L10n.Analyzer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.8.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.13.0" />
<PackageReference Update="NETStandard.Library" PrivateAssets="all" />
</ItemGroup>

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

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<StartupObject>MN.L10n.BuildTasks.Program</StartupObject>
Expand Down
8 changes: 4 additions & 4 deletions MN.L10n.Javascript.Core/MN.L10n.Javascript.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<RepositoryUrl>https://github.com/MultinetInteractive/MN.L10n</RepositoryUrl>
<PackageProjectUrl>https://github.com/MultinetInteractive/MN.L10n</PackageProjectUrl>
Expand All @@ -11,9 +11,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="2.3.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Nullable>Enable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageVersion>3.0.0</PackageVersion>
Expand Down
2 changes: 1 addition & 1 deletion MN.L10n.TestWebApp/MN.L10n.TestWebApp.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>TheTest</RootNamespace>
<Authors>lice, chbe</Authors>
<RepositoryUrl>https://github.com/MultinetInteractive/MN.L10n</RepositoryUrl>
Expand Down
12 changes: 6 additions & 6 deletions MN.L10n.Tests/MN.L10n.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FakeItEasy" Version="8.1.0" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="FakeItEasy" Version="8.3.0" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.5" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 2 additions & 0 deletions MN.L10n.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
.github\workflows\codeql-analysis.yml = .github\workflows\codeql-analysis.yml
CONTRIBUTING.md = CONTRIBUTING.md
.github\workflows\javascripts-tests.yml = .github\workflows\javascripts-tests.yml
LICENSE.txt = LICENSE.txt
README.md = README.md
TROUBLESHOOTING.md = TROUBLESHOOTING.md
Expand Down
23 changes: 20 additions & 3 deletions MN.L10n/FileProviders/FileDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public class FileDataProvider : IL10nDataProvider
private string LanguagesFile { get; set; }
private string LanguageFile { get; set; }
public bool SaveChangesToDisk { get; set; } = true;


public Action<string, string, Exception>? OnWriteError { get; set; }

public FileDataProvider(string path, string l10nFileName = "phrases.json", string l10nPhraseFileNameFormat = "language-{0}.json", string l10nLanguagesFileName = "languages.json")
{
FilePath = path;
Expand Down Expand Up @@ -157,7 +159,7 @@ public async Task<bool> LoadTranslationFromSources(L10n l10n, bool removeAllPhra
sources.Reverse();

// If we have sources, and the removeAllPhrases is true, remove all current phrases, to get rid of old ones as well
if(sources.Count > 0 && removeAllPhrases)
if (sources.Count > 0 && removeAllPhrases)
{
l10nLang.Phrases.Clear();
}
Expand Down Expand Up @@ -237,7 +239,22 @@ private void WriteToDiskIfAllowed(string pathAndFilename, string contents)
{
if (SaveChangesToDisk)
{
File.WriteAllText(pathAndFilename, contents);
try
{
File.WriteAllText(pathAndFilename, contents);
}
catch (UnauthorizedAccessException uae)
{
Console.WriteLine("error l10n: Unauthorized Access Exception");
Console.WriteLine($"error l10n: Got an error trying to save the file {pathAndFilename}");
Console.WriteLine(uae.ToString());

OnWriteError?.Invoke(pathAndFilename, contents, uae);
}
catch (Exception ex)
{
OnWriteError?.Invoke(pathAndFilename, contents, ex);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion MN.L10n/MN.L10n.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net472;netstandard2.0;net8.0;net9.0</TargetFrameworks>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Company>MultiNet Interactive AB</Company>
<Authors>Chris Gårdenberg</Authors>
Expand Down
2 changes: 1 addition & 1 deletion dotnet-l10n-buildtask/dotnet-l10n-buildtask.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>dotnet_l10n_buildtask</RootNamespace>
<PackAsTool>true</PackAsTool>
<ToolCommandName>l10n-buildtask</ToolCommandName>
Expand Down