Skip to content

Commit

Permalink
Make it easier to augment parts of HotAvalonia
Browse files Browse the repository at this point in the history
 - `AvaloniaHotReloadAttribute` and `AvaloniaHotReloadExtensions` are partial now
 - It's now trivial to define a custom project path resolver: `static string? AvaloniaHotReloadExtensions.ResolveProjectPath(Assembly)`
 - It's now possible to use a custom file system provider:
    1) Define `HOTAVALONIA_USE_CUSTOM_FILE_SYSTEM`
    2) Implement `static IFileSystem AvaloniaHotReloadExtensions.GetFileSystem()`
  • Loading branch information
Kir-Antipov committed Feb 16, 2025
1 parent 2511af9 commit c9cda65
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/HotAvalonia.Extensions/AvaloniaHotReloadExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ namespace HotAvalonia
[ExcludeFromCodeCoverage]
[Conditional("HOTAVALONIA_ENABLE")]
[AttributeUsage(AttributeTargets.Method)]
internal sealed class AvaloniaHotReloadAttribute : Attribute
internal sealed partial class AvaloniaHotReloadAttribute : Attribute
{
}

/// <summary>
/// Provides extension methods for enabling and disabling hot reload functionality for Avalonia applications.
/// </summary>
[ExcludeFromCodeCoverage]
internal static class AvaloniaHotReloadExtensions
internal static partial class AvaloniaHotReloadExtensions
{
#if HOTAVALONIA_ENABLE && !HOTAVALONIA_DISABLE
/// <summary>
Expand Down Expand Up @@ -139,6 +139,7 @@ private static IHotReloadContext CreateHotReloadContext(AvaloniaProjectLocator p
#endif
}

#if !HOTAVALONIA_USE_CUSTOM_FILE_SYSTEM
/// <summary>
/// Gets the current file system instance.
/// </summary>
Expand All @@ -152,6 +153,7 @@ private static IHotReloadContext CreateHotReloadContext(AvaloniaProjectLocator p
return global::HotAvalonia.IO.FileSystem.Current;
#endif
}
#endif
#endif

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/HotAvalonia.Extensions/AvaloniaHotReloadExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ type internal AvaloniaHotReloadExtensions =
AvaloniaHotReloadContext.Create(projectLocator)
#endif

#if !HOTAVALONIA_USE_CUSTOM_FILE_SYSTEM
/// <summary>
/// Gets the current file system instance.
/// </summary>
Expand All @@ -139,6 +140,7 @@ type internal AvaloniaHotReloadExtensions =
#else
HotAvalonia.IO.FileSystem.Current
#endif
#endif
#endif

/// <summary>
Expand Down
6 changes: 4 additions & 2 deletions src/HotAvalonia.Extensions/AvaloniaHotReloadExtensions.vb
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ Namespace Global.HotAvalonia
<ExcludeFromCodeCoverage>
<Conditional("HOTAVALONIA_ENABLE")>
<AttributeUsage(AttributeTargets.Method)>
Friend NotInheritable Class AvaloniaHotReloadAttribute
Friend NotInheritable Partial Class AvaloniaHotReloadAttribute
Inherits Attribute
End Class

''' <summary>
''' Provides extension methods for enabling and disabling hot reload functionality for Avalonia applications.
''' </summary>
<ExcludeFromCodeCoverage>
Friend Module AvaloniaHotReloadExtensions
Friend Partial Module AvaloniaHotReloadExtensions
#If HOTAVALONIA_ENABLE AndAlso Not HOTAVALONIA_DISABLE Then
''' <summary>
''' Creates a factory method for generating an <see cref="IHotReloadContext"/>
Expand Down Expand Up @@ -133,6 +133,7 @@ Namespace Global.HotAvalonia
#End If
End Function

#If Not HOTAVALONIA_USE_CUSTOM_FILE_SYSTEM Then
''' <summary>
''' Gets the current file system instance.
''' </summary>
Expand All @@ -145,6 +146,7 @@ Namespace Global.HotAvalonia
Return HotAvalonia.IO.FileSystem.Current
#End If
End Function
#End If
#End If

''' <summary>
Expand Down

0 comments on commit c9cda65

Please sign in to comment.