diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 4b04851..6a0e5f8 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -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 diff --git a/MN.L10n.Analyzer/MN.L10n.Analyzer.Test/MN.L10n.Analyzer.Test.csproj b/MN.L10n.Analyzer/MN.L10n.Analyzer.Test/MN.L10n.Analyzer.Test.csproj index 0c75db3..78ee7ec 100644 --- a/MN.L10n.Analyzer/MN.L10n.Analyzer.Test/MN.L10n.Analyzer.Test.csproj +++ b/MN.L10n.Analyzer/MN.L10n.Analyzer.Test/MN.L10n.Analyzer.Test.csproj @@ -1,20 +1,20 @@  - net8.0 + net9.0 false - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/MN.L10n.Analyzer/MN.L10n.Analyzer/MN.L10n.Analyzer.csproj b/MN.L10n.Analyzer/MN.L10n.Analyzer/MN.L10n.Analyzer.csproj index 732381b..6ae1812 100644 --- a/MN.L10n.Analyzer/MN.L10n.Analyzer/MN.L10n.Analyzer.csproj +++ b/MN.L10n.Analyzer/MN.L10n.Analyzer/MN.L10n.Analyzer.csproj @@ -30,7 +30,7 @@ - + diff --git a/MN.L10n.BuildTasks/MN.L10n.BuildTasks.csproj b/MN.L10n.BuildTasks/MN.L10n.BuildTasks.csproj index 07112e9..a4625e6 100644 --- a/MN.L10n.BuildTasks/MN.L10n.BuildTasks.csproj +++ b/MN.L10n.BuildTasks/MN.L10n.BuildTasks.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 Exe MN.L10n.BuildTasks.Program diff --git a/MN.L10n.Javascript.Core/MN.L10n.Javascript.Core.csproj b/MN.L10n.Javascript.Core/MN.L10n.Javascript.Core.csproj index 69ffcec..0b5a79a 100644 --- a/MN.L10n.Javascript.Core/MN.L10n.Javascript.Core.csproj +++ b/MN.L10n.Javascript.Core/MN.L10n.Javascript.Core.csproj @@ -1,7 +1,7 @@  - net6.0;net7.0;net8.0 + net8.0;net9.0 True https://github.com/MultinetInteractive/MN.L10n https://github.com/MultinetInteractive/MN.L10n @@ -11,9 +11,9 @@ - - - + + + diff --git a/MN.L10n.JavascriptTranslationMiddleware/MN.L10n.JavascriptTranslationMiddleware.csproj b/MN.L10n.JavascriptTranslationMiddleware/MN.L10n.JavascriptTranslationMiddleware.csproj index 43490b4..4273de2 100644 --- a/MN.L10n.JavascriptTranslationMiddleware/MN.L10n.JavascriptTranslationMiddleware.csproj +++ b/MN.L10n.JavascriptTranslationMiddleware/MN.L10n.JavascriptTranslationMiddleware.csproj @@ -1,7 +1,7 @@ - net6.0;net7.0;net8.0 + net8.0;net9.0 Enable True 3.0.0 diff --git a/MN.L10n.TestWebApp/MN.L10n.TestWebApp.csproj b/MN.L10n.TestWebApp/MN.L10n.TestWebApp.csproj index 8d20d46..38bf165 100644 --- a/MN.L10n.TestWebApp/MN.L10n.TestWebApp.csproj +++ b/MN.L10n.TestWebApp/MN.L10n.TestWebApp.csproj @@ -1,6 +1,6 @@ - net8.0 + net9.0 TheTest lice, chbe https://github.com/MultinetInteractive/MN.L10n diff --git a/MN.L10n.Tests/MN.L10n.Tests.csproj b/MN.L10n.Tests/MN.L10n.Tests.csproj index 291fa93..6f83247 100644 --- a/MN.L10n.Tests/MN.L10n.Tests.csproj +++ b/MN.L10n.Tests/MN.L10n.Tests.csproj @@ -1,19 +1,19 @@  - net8.0 + net9.0 false - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/MN.L10n.sln b/MN.L10n.sln index c25c380..8c9202c 100644 --- a/MN.L10n.sln +++ b/MN.L10n.sln @@ -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 diff --git a/MN.L10n/FileProviders/FileDataProvider.cs b/MN.L10n/FileProviders/FileDataProvider.cs index 982d1e6..5aaf4fa 100644 --- a/MN.L10n/FileProviders/FileDataProvider.cs +++ b/MN.L10n/FileProviders/FileDataProvider.cs @@ -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? OnWriteError { get; set; } + public FileDataProvider(string path, string l10nFileName = "phrases.json", string l10nPhraseFileNameFormat = "language-{0}.json", string l10nLanguagesFileName = "languages.json") { FilePath = path; @@ -157,7 +159,7 @@ public async Task 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(); } @@ -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); + } } } } diff --git a/MN.L10n/MN.L10n.csproj b/MN.L10n/MN.L10n.csproj index 253870d..18f36b5 100644 --- a/MN.L10n/MN.L10n.csproj +++ b/MN.L10n/MN.L10n.csproj @@ -1,7 +1,7 @@  - net472;netstandard2.0;net6.0;net7.0;net8.0 + net472;netstandard2.0;net8.0;net9.0 True MultiNet Interactive AB Chris Gårdenberg diff --git a/dotnet-l10n-buildtask/dotnet-l10n-buildtask.csproj b/dotnet-l10n-buildtask/dotnet-l10n-buildtask.csproj index 4ef67de..36a3280 100644 --- a/dotnet-l10n-buildtask/dotnet-l10n-buildtask.csproj +++ b/dotnet-l10n-buildtask/dotnet-l10n-buildtask.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net9.0 dotnet_l10n_buildtask true l10n-buildtask