diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 7d8ffd2e..9afd52b3 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,7 +1,7 @@ - $(TargetFrameworks);net8.0 + net8.0 diff --git a/src/MudBlazor.Examples.Data/PeriodicTableService.cs b/src/MudBlazor.Examples.Data/PeriodicTableService.cs index 9e0bec97..f1da1090 100644 --- a/src/MudBlazor.Examples.Data/PeriodicTableService.cs +++ b/src/MudBlazor.Examples.Data/PeriodicTableService.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Threading.Tasks; using System.Text.Json; +using System.Threading.Tasks; using MudBlazor.Examples.Data.Models; namespace MudBlazor.Examples.Data @@ -20,7 +20,7 @@ public async Task> GetElements(string search = "") var elements = new List(); var key = GetResourceKey(typeof(PeriodicTableService).Assembly, "Elements.json"); using var stream = typeof(PeriodicTableService).Assembly.GetManifestResourceStream(key); - var table = await JsonSerializer.DeserializeAsync(stream, new JsonSerializerOptions(){ PropertyNameCaseInsensitive = true }); + var table = await JsonSerializer.DeserializeAsync
(stream, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true }); foreach (var elementGroup in table.ElementGroups) { elements = elements.Concat(elementGroup.Elements).ToList(); diff --git a/src/Try.Tests/SnippetsServiceTests.cs b/src/Try.Tests/SnippetsServiceTests.cs index 53b8de02..1dd2db9d 100644 --- a/src/Try.Tests/SnippetsServiceTests.cs +++ b/src/Try.Tests/SnippetsServiceTests.cs @@ -1,13 +1,13 @@ namespace Tests { + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using Microsoft.Extensions.Options; using NUnit.Framework; - using TryMudBlazor.Client.Services; - using TryMudBlazor.Client.Models; using Try.Core; - using Microsoft.Extensions.Options; - using System.Threading.Tasks; - using System.Collections.Generic; - using System; + using TryMudBlazor.Client.Models; + using TryMudBlazor.Client.Services; using static TryMudBlazor.Server.Utilities.SnippetsEncoder; /// @@ -33,7 +33,7 @@ public void Setup() var codeFile2 = new CodeFile() { Path = "Test.razor" }; codeFile2.Content = "

Test

"; codeFiles.Add(codeFile2); - snippetsOptions = Options.Create(new SnippetsOptions(){SnippetsService = "api/snippets"}); + snippetsOptions = Options.Create(new SnippetsOptions() { SnippetsService = "api/snippets" }); } @@ -57,10 +57,10 @@ public async Task TestPut() Console.WriteLine(id); var savedCodeFiles = await snippetService.GetSnippetContentAsync(id); List savedCodeFilesList = new List(savedCodeFiles); - for (int i = 0; i < codeFiles.Count; i++ ) + for (int i = 0; i < codeFiles.Count; i++) { Assert.That(codeFiles[i].Path, Is.EqualTo(savedCodeFilesList[i].Path)); - Assert.That(codeFiles[i].Content, Is.EqualTo(savedCodeFilesList[i].Content)); + Assert.That(codeFiles[i].Content, Is.EqualTo(savedCodeFilesList[i].Content)); } } diff --git a/src/TryMudBlazor.Client/Components/CodeEditor.razor.cs b/src/TryMudBlazor.Client/Components/CodeEditor.razor.cs index 940a48b2..4e7a8d2a 100644 --- a/src/TryMudBlazor.Client/Components/CodeEditor.razor.cs +++ b/src/TryMudBlazor.Client/Components/CodeEditor.razor.cs @@ -1,12 +1,12 @@ namespace TryMudBlazor.Client.Components { using System; + using System.Text.RegularExpressions; using System.Threading.Tasks; - using Try.Core; - using TryMudBlazor.Client.Models; using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; - using System.Text.RegularExpressions; + using Try.Core; + using TryMudBlazor.Client.Models; public partial class CodeEditor : IDisposable { diff --git a/src/TryMudBlazor.Client/Components/ErrorList.razor.cs b/src/TryMudBlazor.Client/Components/ErrorList.razor.cs index 07f9d457..e6e5ab46 100644 --- a/src/TryMudBlazor.Client/Components/ErrorList.razor.cs +++ b/src/TryMudBlazor.Client/Components/ErrorList.razor.cs @@ -3,8 +3,8 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; - using Try.Core; using Microsoft.AspNetCore.Components; + using Try.Core; public partial class ErrorList { diff --git a/src/TryMudBlazor.Client/Components/SaveSnippetPopup.razor.cs b/src/TryMudBlazor.Client/Components/SaveSnippetPopup.razor.cs index 39fcde89..03123f65 100644 --- a/src/TryMudBlazor.Client/Components/SaveSnippetPopup.razor.cs +++ b/src/TryMudBlazor.Client/Components/SaveSnippetPopup.razor.cs @@ -4,12 +4,12 @@ namespace TryMudBlazor.Client.Components using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; - using TryMudBlazor.Client.Services; - using TryMudBlazor.Client.Models; - using Try.Core; using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; using MudBlazor; + using Try.Core; + using TryMudBlazor.Client.Models; + using TryMudBlazor.Client.Services; public partial class SaveSnippetPopup { diff --git a/src/TryMudBlazor.Client/Components/TabManager.razor.cs b/src/TryMudBlazor.Client/Components/TabManager.razor.cs index 9a2e1b3a..51a92599 100644 --- a/src/TryMudBlazor.Client/Components/TabManager.razor.cs +++ b/src/TryMudBlazor.Client/Components/TabManager.razor.cs @@ -2,9 +2,9 @@ { using System.Collections.Generic; using System.Threading.Tasks; - using Services; using Microsoft.AspNetCore.Components; using MudBlazor; + using Services; public partial class TabManager { diff --git a/src/TryMudBlazor.Client/Pages/Repl.razor.cs b/src/TryMudBlazor.Client/Pages/Repl.razor.cs index d921f4e1..72733917 100644 --- a/src/TryMudBlazor.Client/Pages/Repl.razor.cs +++ b/src/TryMudBlazor.Client/Pages/Repl.razor.cs @@ -5,19 +5,19 @@ using System.IO; using System.Linq; using System.Threading.Tasks; - using TryMudBlazor.Client.Components; - using TryMudBlazor.Client.Services; - using TryMudBlazor.Client.Models; - using Try.Core; using Microsoft.AspNetCore.Components; using Microsoft.CodeAnalysis; using Microsoft.JSInterop; using MudBlazor; + using Try.Core; + using TryMudBlazor.Client.Components; + using TryMudBlazor.Client.Models; + using TryMudBlazor.Client.Services; public partial class Repl : IDisposable { [Inject] private LayoutService LayoutService { get; set; } - + private const string MainComponentCodePrefix = "@page \"/__main\"\n"; private const string MainUserPagePath = "/__main"; diff --git a/src/TryMudBlazor.Client/Program.cs b/src/TryMudBlazor.Client/Program.cs index 4be6441b..9676f3d0 100644 --- a/src/TryMudBlazor.Client/Program.cs +++ b/src/TryMudBlazor.Client/Program.cs @@ -6,19 +6,19 @@ namespace TryMudBlazor.Client using System.Reflection; using System.Threading.Tasks; using Blazored.LocalStorage; - using TryMudBlazor.Client.Models; - using TryMudBlazor.Client.Services; - using Try.Core; + using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; + using Microsoft.AspNetCore.Components.WebAssembly.Services; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.JSInterop; using MudBlazor.Services; using Services.UserPreferences; + using Try.Core; using Try.UserComponents; - using Microsoft.AspNetCore.Components.WebAssembly.Services; - using Microsoft.AspNetCore.Components.Web; + using TryMudBlazor.Client.Models; + using TryMudBlazor.Client.Services; public class Program { @@ -97,7 +97,7 @@ private static IJSInProcessRuntime GetJsRuntime() { throw new MissingMemberException($"Couldn't find property '{instanceFieldName}' in '{defaultJsRuntimeTypeName}'."); } - + return (IJSInProcessRuntime)instanceField.GetValue(obj: null); } } diff --git a/src/TryMudBlazor.Client/Services/CodeFilesHelper.cs b/src/TryMudBlazor.Client/Services/CodeFilesHelper.cs index c624e73f..8a1d64ac 100644 --- a/src/TryMudBlazor.Client/Services/CodeFilesHelper.cs +++ b/src/TryMudBlazor.Client/Services/CodeFilesHelper.cs @@ -5,9 +5,9 @@ using System.IO; using System.IO.Compression; using System.Text; - using Try.Core; using Microsoft.AspNetCore.WebUtilities; using Microsoft.CodeAnalysis.CSharp; + using Try.Core; public static class CodeFilesHelper { diff --git a/src/TryMudBlazor.Client/Services/HandleCriticalUserComponentExceptionsLogger.cs b/src/TryMudBlazor.Client/Services/HandleCriticalUserComponentExceptionsLogger.cs index 5923c8b0..e6a8f488 100644 --- a/src/TryMudBlazor.Client/Services/HandleCriticalUserComponentExceptionsLogger.cs +++ b/src/TryMudBlazor.Client/Services/HandleCriticalUserComponentExceptionsLogger.cs @@ -1,9 +1,9 @@ namespace TryMudBlazor.Client.Services { using System; - using Try.Core; using Microsoft.Extensions.Logging; using Microsoft.JSInterop; + using Try.Core; using TryMudBlazor.Client.Models; // This is a workaround for the currently missing global exception handling mechanism in Blazor. If the user code generates diff --git a/src/TryMudBlazor.Client/Services/LayoutService.cs b/src/TryMudBlazor.Client/Services/LayoutService.cs index f80038e4..ace19f91 100644 --- a/src/TryMudBlazor.Client/Services/LayoutService.cs +++ b/src/TryMudBlazor.Client/Services/LayoutService.cs @@ -8,19 +8,19 @@ public class LayoutService { private readonly IUserPreferencesService _userPreferencesService; private UserPreferences.UserPreferences _userPreferences; - + public bool IsDarkMode { get; private set; } = false; - + public LayoutService(IUserPreferencesService userPreferencesService) { _userPreferencesService = userPreferencesService; } - + public void SetDarkMode(bool value) { IsDarkMode = value; } - + public async Task ApplyUserPreferences(bool isDarkModeDefaultTheme) { _userPreferences = await _userPreferencesService.LoadUserPreferences(); @@ -31,15 +31,15 @@ public async Task ApplyUserPreferences(bool isDarkModeDefaultTheme) else { IsDarkMode = isDarkModeDefaultTheme; - _userPreferences = new UserPreferences.UserPreferences {DarkTheme = IsDarkMode}; + _userPreferences = new UserPreferences.UserPreferences { DarkTheme = IsDarkMode }; await _userPreferencesService.SaveUserPreferences(_userPreferences); } } - + public event EventHandler MajorUpdateOccured; - private void OnMajorUpdateOccured() => MajorUpdateOccured?.Invoke(this,EventArgs.Empty); - + private void OnMajorUpdateOccured() => MajorUpdateOccured?.Invoke(this, EventArgs.Empty); + public async Task ToggleDarkMode() { IsDarkMode = !IsDarkMode; diff --git a/src/TryMudBlazor.Client/Services/SnippetsService.cs b/src/TryMudBlazor.Client/Services/SnippetsService.cs index 0bebdd93..89a7b524 100644 --- a/src/TryMudBlazor.Client/Services/SnippetsService.cs +++ b/src/TryMudBlazor.Client/Services/SnippetsService.cs @@ -7,10 +7,10 @@ using System.Net.Http; using System.Text; using System.Threading.Tasks; - using TryMudBlazor.Client.Models; - using Try.Core; using Microsoft.AspNetCore.Components; using Microsoft.Extensions.Options; + using Try.Core; + using TryMudBlazor.Client.Models; public class SnippetsService { diff --git a/src/TryMudBlazor.Client/Services/UserPreferences/UserPreferencesService.cs b/src/TryMudBlazor.Client/Services/UserPreferences/UserPreferencesService.cs index 88907e61..d16fdb04 100644 --- a/src/TryMudBlazor.Client/Services/UserPreferences/UserPreferencesService.cs +++ b/src/TryMudBlazor.Client/Services/UserPreferences/UserPreferencesService.cs @@ -10,24 +10,24 @@ public interface IUserPreferencesService ///
/// The userPreferences to save in the local storage public Task SaveUserPreferences(UserPreferences userPreferences); - + /// /// Loads UserPreferences in local storage /// /// UserPreferences object. Null when no settings were found. public Task LoadUserPreferences(); } - + public class UserPreferencesService : IUserPreferencesService { private readonly ILocalStorageService _localStorage; private const string Key = "userPreferences"; - + public UserPreferencesService(ILocalStorageService localStorage) { _localStorage = localStorage; } - + public async Task SaveUserPreferences(UserPreferences userPreferences) { await _localStorage.SetItemAsync(Key, userPreferences); diff --git a/src/TryMudBlazor.Client/Shared/MainLayout.razor.cs b/src/TryMudBlazor.Client/Shared/MainLayout.razor.cs index 0b733915..e43335a0 100644 --- a/src/TryMudBlazor.Client/Shared/MainLayout.razor.cs +++ b/src/TryMudBlazor.Client/Shared/MainLayout.razor.cs @@ -3,10 +3,10 @@ using System; using System.Net.Http; using System.Threading.Tasks; - using Try.Core; using Microsoft.AspNetCore.Components; - using Services; using MudBlazor; + using Services; + using Try.Core; using TryMudBlazor.Client; public partial class MainLayout : LayoutComponentBase, IDisposable @@ -21,25 +21,25 @@ protected override void OnInitialized() LayoutService.MajorUpdateOccured += LayoutServiceOnMajorUpdateOccured; base.OnInitialized(); } - + protected override async Task OnInitializedAsync() { await CompilationService.InitAsync(this.HttpClient); await base.OnInitializedAsync(); } - + protected override async Task OnAfterRenderAsync(bool firstRender) { await base.OnAfterRenderAsync(firstRender); - + if (firstRender) { await ApplyUserPreferences(); StateHasChanged(); } } - + private async Task ApplyUserPreferences() { var defaultDarkMode = await _mudThemeProvider.GetSystemPreference();