Skip to content

Commit

Permalink
Code Quality: dotnet format (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikes-gh authored Mar 29, 2024
1 parent 32383f1 commit ef3e379
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 53 deletions.
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<PropertyGroup>
<TargetFrameworks>$(TargetFrameworks);net8.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
</PropertyGroup>

</Project>
4 changes: 2 additions & 2 deletions src/MudBlazor.Examples.Data/PeriodicTableService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,7 +20,7 @@ public async Task<IEnumerable<Element>> GetElements(string search = "")
var elements = new List<Element>();
var key = GetResourceKey(typeof(PeriodicTableService).Assembly, "Elements.json");
using var stream = typeof(PeriodicTableService).Assembly.GetManifestResourceStream(key);
var table = await JsonSerializer.DeserializeAsync<Table>(stream, new JsonSerializerOptions(){ PropertyNameCaseInsensitive = true });
var table = await JsonSerializer.DeserializeAsync<Table>(stream, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true });
foreach (var elementGroup in table.ElementGroups)
{
elements = elements.Concat(elementGroup.Elements).ToList();
Expand Down
18 changes: 9 additions & 9 deletions src/Try.Tests/SnippetsServiceTests.cs
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>
Expand All @@ -33,7 +33,7 @@ public void Setup()
var codeFile2 = new CodeFile() { Path = "Test.razor" };
codeFile2.Content = "<h1>Test</h1>";
codeFiles.Add(codeFile2);
snippetsOptions = Options.Create(new SnippetsOptions(){SnippetsService = "api/snippets"});
snippetsOptions = Options.Create(new SnippetsOptions() { SnippetsService = "api/snippets" });

}

Expand All @@ -57,10 +57,10 @@ public async Task TestPut()
Console.WriteLine(id);
var savedCodeFiles = await snippetService.GetSnippetContentAsync(id);
List<CodeFile> savedCodeFilesList = new List<CodeFile>(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));
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/TryMudBlazor.Client/Components/CodeEditor.razor.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/TryMudBlazor.Client/Components/ErrorList.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
6 changes: 3 additions & 3 deletions src/TryMudBlazor.Client/Components/SaveSnippetPopup.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/TryMudBlazor.Client/Components/TabManager.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
10 changes: 5 additions & 5 deletions src/TryMudBlazor.Client/Pages/Repl.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
12 changes: 6 additions & 6 deletions src/TryMudBlazor.Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -97,7 +97,7 @@ private static IJSInProcessRuntime GetJsRuntime()
{
throw new MissingMemberException($"Couldn't find property '{instanceFieldName}' in '{defaultJsRuntimeTypeName}'.");
}

return (IJSInProcessRuntime)instanceField.GetValue(obj: null);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/TryMudBlazor.Client/Services/CodeFilesHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 8 additions & 8 deletions src/TryMudBlazor.Client/Services/LayoutService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/TryMudBlazor.Client/Services/SnippetsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ public interface IUserPreferencesService
/// </summary>
/// <param name="userPreferences">The userPreferences to save in the local storage</param>
public Task SaveUserPreferences(UserPreferences userPreferences);

/// <summary>
/// Loads UserPreferences in local storage
/// </summary>
/// <returns>UserPreferences object. Null when no settings were found.</returns>
public Task<UserPreferences> 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);
Expand Down
12 changes: 6 additions & 6 deletions src/TryMudBlazor.Client/Shared/MainLayout.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down

0 comments on commit ef3e379

Please sign in to comment.