Skip to content

Commit

Permalink
merge results
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmoradi committed Nov 7, 2024
2 parents 6c9841f + 3d1ece7 commit 2c59d22
Show file tree
Hide file tree
Showing 39 changed files with 530 additions and 322 deletions.
28 changes: 24 additions & 4 deletions .github/workflows/bit.full.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ on:

env:
ConnectionStrings__SqlServerConnectionString: 'Data Source=localhost; Initial Catalog=BoilerplateTestDb;Application Name=Boilerplate;TrustServerCertificate=True;User Id=sa;Password=P@ssw0rdP@ssw0rd;'
SIMPLE_TEST_FILTER: "FullyQualifiedName!~PageTests"
BLAZOR_SERVER_TEST_FILTER: "PageTests.BlazorServer"
BLAZOR_WASM_TEST_FILTER: "PageTests.BlazorWebAssembly"
SIMPLE_TEST_FILTER: "ClassName!~PageTests"
BLAZOR_SERVER_TEST_FILTER: "ClassName~PageTests.BlazorServer"
BLAZOR_WASM_TEST_FILTER: "ClassName~PageTests.BlazorWebAssembly"
MULTILINGUAL_DISABLED_TEST_FILTER: "ClassName!~LocalizationTests|TestCategory=MultilingualDisabled"

jobs:

Expand Down Expand Up @@ -100,7 +101,7 @@ jobs:
- name: Test SqlServer database option
id: sqlserver-test
run: |
dotnet new bit-bp --name TestSqlServer --database SqlServer
dotnet new bit-bp --name TestSqlServer --database SqlServer --advancedTests
cd TestSqlServer/src/Server/TestSqlServer.Server.Api/
dotnet tool restore
dotnet ef migrations add InitialMigration
Expand All @@ -115,6 +116,25 @@ jobs:
path: ./TestSqlServer/src/Tests/TestResults
retention-days: 14

- name: Test Multilingual disabled option
id: multilingual-disabled-test
run: |
dotnet new bit-bp --name MultilingualDisabled --database Sqlite --advancedTests
cd MultilingualDisabled/src/Server/MultilingualDisabled.Server.Api/
dotnet tool restore
dotnet ef migrations add InitialMigration
dotnet ef database update
cd ../../Tests
dotnet test -p:MultilingualEnabled=false --logger GitHubActions --filter "${{ env.MULTILINGUAL_DISABLED_TEST_FILTER }}" -- MSTest.Parallelize.Workers=1
- name: Upload Tests Artifact
uses: actions/[email protected]
if: ${{ !env.ACT && failure() && steps.multilingual-disabled-test.conclusion == 'failure' }}
with:
name: tests-artifact
path: ./MultilingualDisabled/src/Tests/TestResults
retention-days: 14

- name: Test PostgreSQL, Cosmos, MySql, Other database options
run: |
dotnet new bit-bp --name TestPostgreSQL --database PostgreSQL
Expand Down
4 changes: 0 additions & 4 deletions src/BlazorUI/Bit.BlazorUI/Styles/fabric.mdl2.bit.blazoui.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,10 @@

.bit-icon--Accept:before { content: "\E8FB"; }
.bit-icon--Add:before { content: "\E710"; }
.bit-icon--Blocked2:before { content: "\ECE4"; }
.bit-icon--CalendarMirrored:before { content: "\ED28"; }
.bit-icon--Cancel:before { content: "\E711"; }
.bit-icon--ChevronDown:before { content: "\E70D"; }
.bit-icon--ChevronDownSmall:before { content: "\E96E"; }
.bit-icon--ChevronLeft:before { content: "\E76B"; }
.bit-icon--ChevronLeftEnd6:before { content: "\F371"; }
.bit-icon--ChevronLeftSmall:before { content: "\E96F"; }
.bit-icon--ChevronRight:before { content: "\E76C"; }
.bit-icon--ChevronUpSmall:before { content: "\E96D"; }
.bit-icon--ChromeBackMirrored:before { content: "\EA47"; }
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.0-rc.2.24503.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="8.0.93" />
</ItemGroup>

<!-- Build Properties must be defined within these property groups to ensure successful publishing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Wpf" Version="9.0.0-rc.2.24503.2" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2792.45" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2849.39" />
<PackageReference Include="Velopack" Version="0.0.869" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />

Expand Down
4 changes: 2 additions & 2 deletions src/Butil/Demo/Bit.Butil.Demo.Maui/Bit.Butil.Demo.Maui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.0-rc.2.24503.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="9.0.0-rc.2.24503.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0-rc.2.24473.5" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" />

<Using Include="System.Net.Http.Json" />
<Using Include="System.Collections.Concurrent" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.Extensions.Logging;
//#if (signalr == true)
using Microsoft.AspNetCore.SignalR.Client;
using Boilerplate.Client.Core.Services.HttpMessageHandlers;
//#endif
//#if (appInsights == true)
using BlazorApplicationInsights.Interfaces;
Expand All @@ -18,7 +19,6 @@ public partial class ClientAppCoordinator : AppComponentBase
{
//#if (signalr == true)
private HubConnection? hubConnection;
[AutoInject] private IServiceProvider serviceProvider = default!;
//#endif
//#if (notification == true)
[AutoInject] private IPushNotificationService pushNotificationService = default!;
Expand All @@ -28,7 +28,6 @@ public partial class ClientAppCoordinator : AppComponentBase
//#endif
[AutoInject] private Navigator navigator = default!;
[AutoInject] private IJSRuntime jsRuntime = default!;
[AutoInject] private Bit.Butil.Console console = default!;
[AutoInject] private IStorageService storageService = default!;
[AutoInject] private ILogger<ClientAppCoordinator> logger = default!;
[AutoInject] private AuthenticationManager authManager = default!;
Expand Down Expand Up @@ -75,8 +74,6 @@ await storageService.GetItem("Culture") ?? // 2- User settings
}

await SetupBodyClasses();

BrowserConsoleLoggerProvider.SetConsole(console);
}

await base.OnInitAsync();
Expand Down Expand Up @@ -146,8 +143,8 @@ private async Task ConnectSignalR()
// WebSockets should be enabled on services like IIS or Cloudflare CDN, offering significantly better performance.
options.HttpMessageHandlerFactory = signalrHttpMessageHandler =>
{
return serviceProvider.GetRequiredService<Func<HttpMessageHandler, HttpMessageHandler>>()
.Invoke(signalrHttpMessageHandler);
return serviceProvider.GetRequiredService<HttpMessageHandlersChainFactory>()
.Invoke(transportHandler: signalrHttpMessageHandler);
};
})
.Build();
Expand Down Expand Up @@ -240,4 +237,27 @@ protected override async ValueTask DisposeAsync(bool disposing)

await base.DisposeAsync(disposing);
}

[AutoInject]
private IServiceProvider serviceProvider
{
set => currentServiceProvider = value;
get => currentServiceProvider!;
}

private static IServiceProvider? currentServiceProvider;
public static IServiceProvider? CurrentServiceProvider
{
get
{
if (AppPlatform.IsBlazorHybridOrBrowser is false)
throw new InvalidOperationException($"{nameof(CurrentServiceProvider)} is only available in Blazor Hybrid or blazor web assembly.");

return currentServiceProvider;
}
private set
{
currentServiceProvider = value;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Boilerplate.Client.Core;
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Components.WebAssembly.Services;
using Boilerplate.Client.Core.Components;
using Boilerplate.Client.Core.Services.HttpMessageHandlers;

namespace Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -43,6 +44,7 @@ public static IServiceCollection AddClientCoreProjectServices(this IServiceColle
services.AddSessioned(sp => (AuthenticationManager)sp.GetRequiredService<AuthenticationStateProvider>());

services.AddSingleton(sp => configuration.Get<ClientCoreSettings>()!);
services.AddSingleton(_ => new CurrentScopeProvider(() => ClientAppCoordinator.CurrentServiceProvider));

services.AddOptions<ClientCoreSettings>()
.Bind(configuration)
Expand All @@ -55,12 +57,12 @@ public static IServiceCollection AddClientCoreProjectServices(this IServiceColle
// This code constructs a chain of HTTP message handlers. By default, it uses `HttpClientHandler`
// to send requests to the server. However, you can replace `HttpClientHandler` with other HTTP message
// handlers, such as ASP.NET Core's `HttpMessageHandler` from the Test Host, which is useful for integration tests.
services.AddScoped<Func<HttpMessageHandler, HttpMessageHandler>>(serviceProvider => underlyingHttpMessageHandler =>
services.AddScoped<HttpMessageHandlersChainFactory>(serviceProvider => transportHandler =>
{
var constructedHttpMessageHandler = ActivatorUtilities.CreateInstance<RequestHeadersDelegationHandler>(serviceProvider,
[ActivatorUtilities.CreateInstance<AuthDelegatingHandler>(serviceProvider,
[ActivatorUtilities.CreateInstance<RetryDelegatingHandler>(serviceProvider,
[ActivatorUtilities.CreateInstance<ExceptionDelegatingHandler>(serviceProvider, [underlyingHttpMessageHandler])])])]);
[ActivatorUtilities.CreateInstance<ExceptionDelegatingHandler>(serviceProvider, [transportHandler])])])]);
return constructedHttpMessageHandler;
});
services.AddScoped<AuthDelegatingHandler>();
Expand All @@ -69,8 +71,8 @@ public static IServiceCollection AddClientCoreProjectServices(this IServiceColle
services.AddScoped<RequestHeadersDelegationHandler>();
services.AddScoped(serviceProvider =>
{
var underlyingHttpMessageHandler = serviceProvider.GetRequiredService<HttpClientHandler>();
var constructedHttpMessageHandler = serviceProvider.GetRequiredService<Func<HttpMessageHandler, HttpMessageHandler>>().Invoke(underlyingHttpMessageHandler);
var transportHandler = serviceProvider.GetRequiredService<HttpClientHandler>();
var constructedHttpMessageHandler = serviceProvider.GetRequiredService<HttpMessageHandlersChainFactory>().Invoke(transportHandler);
return constructedHttpMessageHandler;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public static async ValueTask<DeviceInstallationDto> GetDeviceInstallation(this
/// </summary>
public static bool IsInitialized(this IJSRuntime jsRuntime)
{
if (jsRuntime is null)
return false;

var type = jsRuntime.GetType();

return type.Name switch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
namespace Microsoft.Extensions.Logging;
using Boilerplate.Client.Core.Services.DiagnosticLog;

namespace Microsoft.Extensions.Logging;

public static class ILoggingBuilderExtensions
{
public static ILoggingBuilder AddBrowserConsoleLogger(this ILoggingBuilder builder)
public static ILoggingBuilder AddDiagnosticLogger(this ILoggingBuilder builder)
{
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerProvider, BrowserConsoleLoggerProvider>());
builder.Services.AddSessioned<DiagnosticLogger>();
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerProvider, DiagnosticLoggerProvider>());

return builder;
}

public static ILoggingBuilder ConfigureLoggers(this ILoggingBuilder loggingBuilder)
{
loggingBuilder.ClearProviders();

if (AppEnvironment.IsDev())
{
loggingBuilder.AddDebug();
}

if (!AppPlatform.IsBrowser)
{
loggingBuilder.AddConsole();
// DiagnosticLogger is already logging in browser's console.
// But Console logger is still useful in Visual Studio's Device Log (Android, iOS) or BrowserStack etc.
}

loggingBuilder.AddDiagnosticLogger();

return loggingBuilder;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Boilerplate.Client.Core.Components;

namespace Boilerplate.Client.Core.Services.Contracts;

/// <summary>
/// Provides the current scope's <see cref="IServiceProvider"/>.
///
/// In different hosting environments, this delegate returns the `IServiceProvider` from:
///
/// - **Blazor Server, SSR, and Pre-rendering:** `HttpContextAccessor.HttpContext.RequestServices`
/// - **Blazor WebAssembly and Hybrid:** Gets it from <see cref="ClientAppCoordinator.CurrentServiceProvider"/>
///
/// The delegate may return `null` in the following scenarios:
///
/// - When there's no active `HttpContext` in backend environments.
/// - When the Routes.razor page is not loaded yet.
/// </summary>
/// <returns>The current scope's `IServiceProvider`, or `null` if not available.</returns>
public delegate IServiceProvider? CurrentScopeProvider();
Loading

0 comments on commit 2c59d22

Please sign in to comment.