Skip to content

Commit acc8fd4

Browse files
committed
chore: remove unused code, clean up, reorder files
1 parent f72cb77 commit acc8fd4

File tree

61 files changed

+525
-1884
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+525
-1884
lines changed

samples/BlazingPizza/Components/Account/IdentityComponentsEndpointRouteBuilderExtensions.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
using System.Security.Claims;
22
using System.Text.Json;
3+
using BlazingPizza.Components.Account.Pages;
4+
using BlazingPizza.Components.Account.Pages.Manage;
5+
using BlazingPizza.Data;
36
using Microsoft.AspNetCore.Authentication;
47
using Microsoft.AspNetCore.Components.Authorization;
58
using Microsoft.AspNetCore.Http.Extensions;
69
using Microsoft.AspNetCore.Identity;
710
using Microsoft.AspNetCore.Mvc;
811
using Microsoft.Extensions.Primitives;
9-
using BlazingPizza.Components.Account.Pages;
10-
using BlazingPizza.Components.Account.Pages.Manage;
11-
using BlazingPizza.Data;
1212

1313
namespace Microsoft.AspNetCore.Routing;
1414

Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
using BlazingPizza.Data;
12
using Microsoft.AspNetCore.Identity;
23
using Microsoft.AspNetCore.Identity.UI.Services;
3-
using BlazingPizza.Data;
44

55
namespace BlazingPizza.Components.Account;
66

@@ -11,10 +11,10 @@ internal sealed class IdentityNoOpEmailSender : IEmailSender<PizzaStoreUser>
1111

1212
public Task SendConfirmationLinkAsync(PizzaStoreUser user, string email, string confirmationLink) =>
1313
emailSender.SendEmailAsync(email, "Confirm your email", $"Please confirm your account by <a href='{confirmationLink}'>clicking here</a>.");
14-
14+
1515
public Task SendPasswordResetLinkAsync(PizzaStoreUser user, string email, string resetLink) =>
1616
emailSender.SendEmailAsync(email, "Reset your password", $"Please reset your password by <a href='{resetLink}'>clicking here</a>.");
17-
17+
1818
public Task SendPasswordResetCodeAsync(PizzaStoreUser user, string email, string resetCode) =>
1919
emailSender.SendEmailAsync(email, "Reset your password", $"Please reset your password using the following code: {resetCode}");
2020
}

samples/BlazingPizza/Components/Account/IdentityUserAccessor.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using Microsoft.AspNetCore.Identity;
21
using BlazingPizza.Data;
2+
using Microsoft.AspNetCore.Identity;
33

44
namespace BlazingPizza.Components.Account;
55

samples/BlazingPizza/Components/Shared/ConfigurePizzaFormData.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ public record class ConfigurePizzaFormData
99

1010
[Required, Range(Pizza.MinimumSize, Pizza.MaximumSize)]
1111
public int Size { get; set; }
12-
12+
1313
public List<int>? Toppings { get; set; }
14-
14+
1515
public int SelectTopping { get; set; }
16-
16+
1717
public int RemoveTopping { get; set; }
1818
}

samples/BlazingPizza/Data/OrderWithStatus.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ namespace BlazingPizza.Data;
44

55
public class OrderWithStatus
66
{
7-
public readonly static TimeSpan PreparationDuration = TimeSpan.FromSeconds(10);
8-
public readonly static TimeSpan DeliveryDuration = TimeSpan.FromMinutes(1); // Unrealistic, but more interesting to watch
7+
public static readonly TimeSpan PreparationDuration = TimeSpan.FromSeconds(10);
8+
public static readonly TimeSpan DeliveryDuration = TimeSpan.FromMinutes(1); // Unrealistic, but more interesting to watch
99

1010
// Set from DB
1111
public Order Order { get; set; } = null!;

samples/BlazorSSR/Components/FlashMessages/FlashMessageQueue.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using Microsoft.AspNetCore.Components;
1+
using System.Collections;
2+
using Microsoft.AspNetCore.Components;
23
using Microsoft.Extensions.Caching.Memory;
3-
using System.Collections;
44

55
namespace BlazorSSR.Components.FlashMessages;
66

samples/BlazorSSR/DiskStorage.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ public async Task Save(IReadOnlyList<Contact> contacts, CancellationToken cancel
1717
{
1818
using var stream = File.Open(ContactsFileName, FileMode.Create);
1919
await JsonSerializer.SerializeAsync(
20-
stream,
21-
contacts.OrderBy(x => x.Id),
22-
contactsFileJsonOptions,
20+
stream,
21+
contacts.OrderBy(x => x.Id),
22+
contactsFileJsonOptions,
2323
cancellationToken);
2424
loadedContacts = null;
2525
}

samples/HtmxBlazorSSR/Components/FlashMessages/FlashMessageQueue.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using Microsoft.AspNetCore.Components;
1+
using System.Collections;
2+
using Microsoft.AspNetCore.Components;
23
using Microsoft.Extensions.Caching.Memory;
3-
using System.Collections;
44

55
namespace HtmxBlazorSSR.Components.FlashMessages;
66

samples/HtmxBlazorSSR/Program.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using HtmxBlazorSSR;
22
using HtmxBlazorSSR.Components;
33
using HtmxBlazorSSR.Components.FlashMessages;
4-
using Htmxor;
5-
using Htmxor.Antiforgery;
64

75
var builder = WebApplication.CreateBuilder(args);
86

src/Htmxor/Builder/HtmxorComponentEndpointDataSource.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Reflection;
2-
using Htmxor.Rendering;
32
using Microsoft.AspNetCore.Antiforgery;
43
using Microsoft.AspNetCore.Components.Endpoints;
54
using Microsoft.AspNetCore.Http;

src/Htmxor/Builder/HtmxorComponentEndpointMatcherPolicy.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
using Htmxor.Http;
2-
using Microsoft.AspNetCore.Components.Endpoints;
3-
using Microsoft.AspNetCore.Http;
1+
using Microsoft.AspNetCore.Http;
42
using Microsoft.AspNetCore.Routing;
53
using Microsoft.AspNetCore.Routing.Matching;
6-
using Microsoft.Extensions.DependencyInjection;
74

85
namespace Htmxor.Builder;
96

src/Htmxor/Builder/HtmxorComponentEndpointRouteBuilderExtensions.cs

+2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
using Microsoft.AspNetCore.Components;
44
using Microsoft.AspNetCore.Routing;
55

6+
#pragma warning disable IDE0130
67
namespace Microsoft.AspNetCore.Builder;
8+
#pragma warning restore IDE0130
79

810
public static class HtmxorComponentEndpointRouteBuilderExtensions
911
{

src/Htmxor/Builder/HtmxorEndpointMetadata.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Htmxor.Http;
2-
using Microsoft.AspNetCore.Components;
32

43
namespace Htmxor.Builder;
54

src/Htmxor/Builder/HtmxorLayoutComponentMetadata.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Diagnostics.CodeAnalysis;
4-
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
1+
using System.Diagnostics.CodeAnalysis;
72

83
namespace Htmxor.Builder;
94

src/Htmxor/Components/HtmxPartial.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Htmxor.Http;
2-
using Microsoft.AspNetCore.Components;
1+
using Microsoft.AspNetCore.Components;
32

43
namespace Htmxor.Components;
54

src/Htmxor/Rendering/DefaultAntiforgeryStateProvider.cs src/Htmxor/DependencyInjection/DefaultAntiforgeryStateProvider.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using Microsoft.AspNetCore.Components.Forms;
77
using Microsoft.AspNetCore.Components.Web;
88

9-
namespace Htmxor.Rendering;
9+
namespace Htmxor.DependencyInjection;
1010

1111
internal class DefaultAntiforgeryStateProvider : AntiforgeryStateProvider, IDisposable
1212
{

src/Htmxor/Rendering/EndpointAntiforgeryStateProvider.cs src/Htmxor/DependencyInjection/EndpointAntiforgeryStateProvider.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using Microsoft.AspNetCore.Components.Forms;
77
using Microsoft.AspNetCore.Http;
88

9-
namespace Htmxor.Rendering;
9+
namespace Htmxor.DependencyInjection;
1010

1111
internal class EndpointAntiforgeryStateProvider(IAntiforgery antiforgery, PersistentComponentState state) : DefaultAntiforgeryStateProvider(state)
1212
{

src/Htmxor/DependencyInjection/HtmxorApplicationBuilderExtensions.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
using Microsoft.AspNetCore.Builder;
99
using Microsoft.AspNetCore.Components;
1010
using Microsoft.AspNetCore.Components.Endpoints;
11-
using Microsoft.AspNetCore.Components.Forms.Mapping;
1211
using Microsoft.AspNetCore.Components.Routing;
13-
using Microsoft.AspNetCore.Components.Web;
1412
using Microsoft.AspNetCore.Http;
1513
using Microsoft.AspNetCore.Routing;
1614
using Microsoft.Extensions.DependencyInjection.Extensions;
1715
using Microsoft.Extensions.Hosting;
1816
using Microsoft.Extensions.Options;
1917

18+
#pragma warning disable IDE0130
2019
namespace Microsoft.Extensions.DependencyInjection;
20+
#pragma warning restore IDE0130
2121

2222
/// <summary>
2323
/// This class has extension methods for <see cref="IHostApplicationBuilder"/> and <see cref="IApplicationBuilder"/>
@@ -48,7 +48,7 @@ public static IRazorComponentsBuilder AddHtmx(this IRazorComponentsBuilder razor
4848
services.AddScoped<IRazorComponentEndpointInvoker>(x => x.GetRequiredService<IHtmxorComponentEndpointInvoker>());
4949

5050
services.Remove(services.Single(x => x.Lifetime is ServiceLifetime.Scoped && x.ServiceType.FullName?.Equals("Microsoft.AspNetCore.Components.Endpoints.EndpointHtmlRenderer") == true));
51-
services.AddScoped<EndpointHtmxorRenderer>();
51+
services.AddScoped<HtmxorRenderer>();
5252

5353
// Adding the same cascading value does not seem to override existing values added previously.
5454
// Instead, the previous value is still used. Is this expected behavior or a bug?
@@ -59,8 +59,8 @@ public static IRazorComponentsBuilder AddHtmx(this IRazorComponentsBuilder razor
5959
.Single(x => x.ImplementationFactory?.Target?.ToString()?.Contains(typeof(HttpContext).FullName!) == true);
6060
services.Remove(existingCascadingHttpContextProvider);
6161

62-
services.AddCascadingValue(sp => sp.GetRequiredService<EndpointHtmxorRenderer>().HttpContext);
63-
services.AddScoped(sp => sp.GetRequiredService<EndpointHtmxorRenderer>().HttpContext!);
62+
services.AddCascadingValue(sp => sp.GetRequiredService<HtmxorRenderer>().HttpContext);
63+
services.AddScoped(sp => sp.GetRequiredService<HtmxorRenderer>().HttpContext!);
6464

6565
services.Remove(services.Single(x => x.ServiceType == typeof(NavigationManager)));
6666
services.AddScoped<NavigationManager, HtmxorNavigationManager>();
@@ -75,7 +75,7 @@ public static IRazorComponentsBuilder AddHtmx(this IRazorComponentsBuilder razor
7575
configurHtmx?.Invoke(config);
7676
return config;
7777
});
78-
services.AddScoped(srv => srv.GetRequiredService<EndpointHtmxorRenderer>().HttpContext!.GetHtmxContext());
78+
services.AddScoped(srv => srv.GetRequiredService<HtmxorRenderer>().HttpContext!.GetHtmxContext());
7979
services.AddCascadingValue(sp => sp.GetRequiredService<HtmxContext>());
8080

8181
return razorComponentsBuilder;

src/Htmxor/EventHandlers.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ namespace Htmxor;
55
/// <summary>
66
/// Custom Htmxor Blazor event handlers.
77
/// </summary>
8-
[EventHandler("onget", typeof(HtmxContextEventArgs), enableStopPropagation: false, enablePreventDefault: false)]
9-
[EventHandler("onpost", typeof(HtmxContextEventArgs), enableStopPropagation: false, enablePreventDefault: false)]
10-
[EventHandler("onput", typeof(HtmxContextEventArgs), enableStopPropagation: false, enablePreventDefault: false)]
11-
[EventHandler("onpatch", typeof(HtmxContextEventArgs), enableStopPropagation: false, enablePreventDefault: false)]
12-
[EventHandler("ondelete", typeof(HtmxContextEventArgs), enableStopPropagation: false, enablePreventDefault: false)]
8+
[EventHandler("onget", typeof(HtmxEventArgs), enableStopPropagation: false, enablePreventDefault: false)]
9+
[EventHandler("onpost", typeof(HtmxEventArgs), enableStopPropagation: false, enablePreventDefault: false)]
10+
[EventHandler("onput", typeof(HtmxEventArgs), enableStopPropagation: false, enablePreventDefault: false)]
11+
[EventHandler("onpatch", typeof(HtmxEventArgs), enableStopPropagation: false, enablePreventDefault: false)]
12+
[EventHandler("ondelete", typeof(HtmxEventArgs), enableStopPropagation: false, enablePreventDefault: false)]
1313
public static class EventHandlers
1414
{
1515
}

src/Htmxor/HtmxConfig.cs

+2-25
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
using System.Text.Json;
21
using System.Text.Json.Serialization;
3-
using System.Text.Json.Serialization.Metadata;
42
using Htmxor.Antiforgery;
53

64
namespace Htmxor;
75

86
/// <summary>
97
/// Htmx configuration options.
108
/// </summary>
11-
public record class HtmxConfig
9+
public partial record class HtmxConfig
1210
{
1311
/// <summary>
1412
/// Defaults to <see langword="true" /> if this property is null. really only useful for testing
@@ -211,27 +209,6 @@ public record class HtmxConfig
211209
[JsonPropertyName("scrollIntoViewOnBoost")]
212210
public bool? ScrollIntoViewOnBoost { get; set; }
213211

214-
//// V2 feature
215-
//[JsonPropertyName("responseHandling")]
216-
//public IList<ResponseHandlingRule>? ResponseHandling { get; set; }
217-
218212
[JsonInclude, JsonPropertyName("antiforgery")]
219213
internal HtmxAntiforgeryOptions? Antiforgery { get; init; }
220-
}
221-
222-
//public record class ResponseHandlingRule
223-
//{
224-
// public required string Code { get; set; }
225-
//
226-
// public bool Swap { get; set; }
227-
//
228-
// public bool? Error { get; set; }
229-
//
230-
// public bool? IgnoreTitle { get; set; }
231-
//
232-
// public string? Select { get; set; }
233-
//
234-
// public string? Target { get; set; }
235-
//
236-
// public string? SwapOverride { get; set; }
237-
//}
214+
}

src/Htmxor/HtmxContextEventArgs.cs src/Htmxor/HtmxEventArgs.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
namespace Htmxor;
44

5-
public class HtmxContextEventArgs : EventArgs
5+
public class HtmxEventArgs : EventArgs
66
{
77
private readonly HtmxContext context;
88

99
public HtmxRequest Request { get; }
1010

1111
public HtmxResponse Response { get; }
1212

13-
public HtmxContextEventArgs(HtmxContext context)
13+
public HtmxEventArgs(HtmxContext context)
1414
{
1515
Request = context.Request;
1616
Response = context.Response;
1717
this.context = context;
1818
}
19-
}
19+
}

0 commit comments

Comments
 (0)