Skip to content

Commit 2760369

Browse files
committed
upstream 1.3
1 parent 7e6c379 commit 2760369

File tree

8 files changed

+58
-12
lines changed

8 files changed

+58
-12
lines changed

extensions/Sisk.IniConfiguration/Sisk.IniConfiguration.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<AssemblyVersion>1.3.0</AssemblyVersion>
2525
<FileVersion>1.3.0</FileVersion>
26-
<Version>1.3.0-beta1</Version>
26+
<Version>1.3.0</Version>
2727

2828
<NeutralLanguage>en</NeutralLanguage>
2929
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>

extensions/Sisk.SslProxy/Sisk.SslProxy.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<PackageTags>http-server,http,web framework</PackageTags>
2323
<RepositoryType>git</RepositoryType>
2424

25-
<Version>1.3-alpha6</Version>
25+
<Version>1.3-alpha7</Version>
2626
<AssemblyVersion>1.3</AssemblyVersion>
2727
<FileVersion>1.3</FileVersion>
2828

src/Http/Hosting/HttpServerHostContextBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public HttpServerHostContextBuilder UseRouter(Router r)
266266
/// This method is an shortcut for calling <see cref="Router.AutoScanModules{T}()"/>.
267267
/// </summary>
268268
/// <typeparam name="TModule">An class which implements <see cref="RouterModule"/>, or the router module itself.</typeparam>
269-
[RequiresUnreferencedCode(SR.Router_AutoScanModules_RequiresUnreferencedCode)]
269+
[RequiresUnreferencedCode(SR.RequiresUnreferencedCode)]
270270
public HttpServerHostContextBuilder UseAutoScan<TModule>() where TModule : RouterModule
271271
{
272272
this._context.Router.AutoScanModules<TModule>(typeof(TModule).Assembly);
@@ -278,7 +278,7 @@ public HttpServerHostContextBuilder UseAutoScan<TModule>() where TModule : Route
278278
/// </summary>
279279
/// <typeparam name="TModule">An class which implements <see cref="RouterModule"/>, or the router module itself.</typeparam>
280280
/// <param name="t">The assembly where the scanning types are.</param>
281-
[RequiresUnreferencedCode(SR.Router_AutoScanModules_RequiresUnreferencedCode)]
281+
[RequiresUnreferencedCode(SR.RequiresUnreferencedCode)]
282282
public HttpServerHostContextBuilder UseAutoScan<TModule>(Assembly t) where TModule : RouterModule
283283
{
284284
this._context.Router.AutoScanModules<TModule>(t);

src/Http/HttpContext.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
// Repository: https://github.com/sisk-http/core
99

1010
using Sisk.Core.Entity;
11+
using Sisk.Core.Internal;
1112
using Sisk.Core.Routing;
13+
using System.Diagnostics.CodeAnalysis;
1214

1315
namespace Sisk.Core.Http
1416
{
@@ -17,14 +19,15 @@ namespace Sisk.Core.Http
1719
/// </summary>
1820
public sealed class HttpContext
1921
{
20-
internal static AsyncLocal<HttpContext?> _context = new AsyncLocal<HttpContext?>();
22+
internal readonly static AsyncLocal<HttpContext?> _context = new AsyncLocal<HttpContext?>();
2123

2224
/// <summary>
2325
/// Gets the current running <see cref="HttpContext"/>.
2426
/// </summary>
2527
/// <remarks>
2628
/// This property is only accessible during an HTTP session, within the executing HTTP code.
2729
/// </remarks>
30+
[Experimental(DiagnosticId.Sisk_HttpContext_Current_Experimental)]
2831
public static HttpContext Current { get => _context.Value ?? throw new InvalidOperationException(SR.HttpContext_InvalidThreadStaticAccess); }
2932

3033
/// <summary>

src/Internal/DiagnosticId.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// The Sisk Framework source code
2+
// Copyright (c) 2024 PROJECT PRINCIPIUM
3+
//
4+
// The code below is licensed under the MIT license as
5+
// of the date of its publication, available at
6+
//
7+
// File name: DiagnosticId.cs
8+
// Repository: https://github.com/sisk-http/core
9+
10+
namespace Sisk.Core.Internal;
11+
12+
static class DiagnosticId
13+
{
14+
public const string Sisk_HttpContext_Current_Experimental = "SISK0230";
15+
}

src/Internal/SR.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ static partial class SR
5959

6060
public const string HttpRequestEventSource_KeepAliveDisposed = "Cannot keep alive an instance that has it's connection disposed.";
6161

62-
public const string Router_AutoScanModules_RequiresUnreferencedCode = "This method needs to search for types in your assembly, which can be trimmed in an AOT compilation.";
6362
public const string Router_AutoScanModules_TModuleSameAssembly = "The TModule generic type must be a type that implements RouterModule and not RouterModule itself.";
6463
public const string Router_Set_Collision = "A possible route collision could happen between route {0} and route {1}. Please review the methods and paths of these routes.";
6564
public const string Router_Set_Exception = "Couldn't set method {0}.{1} as an route. See inner exception.";
@@ -101,6 +100,9 @@ static partial class SR
101100

102101
public const string Collection_ReadOnly = "Cannot insert items to this collection as it is read-only.";
103102

103+
public const string RequiresUnreferencedCode = "This method requires access to unreferenced code, which may break AOT compilation and trimming.";
104+
public const string RequiresUnreferencedCode__RouterSetObject = "This method requires access to unreferenced code, which may break AOT compilation and trimming. Use the SetObject(Type, Object) or SetObject<TObject>(TObject) overloads instead.";
105+
104106
public static string Format(string format, params object?[] items)
105107
{
106108
return String.Format(format, items);

src/Routing/Router__CoreSetters.cs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public bool IsDefined(RouteMethod method, string path)
8181
/// </summary>
8282
/// <param name="moduleType">An class which implements <see cref="RouterModule"/>, or the router module itself.</param>
8383
/// <param name="searchAssembly">The assembly to search the module type in.</param>
84-
[RequiresUnreferencedCode(SR.Router_AutoScanModules_RequiresUnreferencedCode)]
84+
[RequiresUnreferencedCode(SR.RequiresUnreferencedCode)]
8585
public void AutoScanModules(Type moduleType, Assembly searchAssembly)
8686
{
8787
if (moduleType == typeof(RouterModule))
@@ -129,7 +129,7 @@ Abstract classes should not be included on the router.
129129
/// </summary>
130130
/// <typeparam name="TModule">An class which implements <see cref="RouterModule"/>, or the router module itself.</typeparam>
131131
/// <param name="assembly">The assembly to search <typeparamref name="TModule"/> in.</param>
132-
[RequiresUnreferencedCode(SR.Router_AutoScanModules_RequiresUnreferencedCode)]
132+
[RequiresUnreferencedCode(SR.RequiresUnreferencedCode)]
133133
public void AutoScanModules<TModule>(Assembly assembly) where TModule : RouterModule
134134
=> this.AutoScanModules(typeof(TModule), assembly);
135135

@@ -139,7 +139,7 @@ public void AutoScanModules<TModule>(Assembly assembly) where TModule : RouterMo
139139
/// for each type must be present.
140140
/// </summary>
141141
/// <typeparam name="TModule">An class which implements <see cref="RouterModule"/>, or the router module itself.</typeparam>
142-
[RequiresUnreferencedCode(SR.Router_AutoScanModules_RequiresUnreferencedCode)]
142+
[RequiresUnreferencedCode(SR.RequiresUnreferencedCode)]
143143
public void AutoScanModules<TModule>() where TModule : RouterModule
144144
=> this.AutoScanModules<TModule>(typeof(TModule).Assembly);
145145

@@ -273,6 +273,7 @@ public void SetRoute(Route r)
273273
/// </summary>
274274
/// <param name="attrClassInstance">The instance of the class where the methods are. The routing methods must be marked with any <see cref="RouteAttribute"/>.</param>
275275
/// <exception cref="Exception">An exception is thrown when a method has an erroneous signature.</exception>
276+
[RequiresUnreferencedCode(SR.RequiresUnreferencedCode__RouterSetObject)]
276277
public void SetObject(object attrClassInstance)
277278
{
278279
Type attrClassType = attrClassInstance.GetType();
@@ -286,13 +287,25 @@ public void SetObject(object attrClassInstance)
286287
/// for these methods.
287288
/// </summary>
288289
/// <param name="attrClassType">The type of the class where the methods are. The routing methods must be marked with any <see cref="RouteAttribute"/>.</param>
289-
/// <exception cref="Exception">An exception is thrown when a method has an erroneous signature.</exception>
290290
public void SetObject([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type attrClassType)
291291
{
292292
MethodInfo[] methods = attrClassType.GetMethods(SetObjectBindingFlag);
293293
this.SetObjectInternal(methods, attrClassType, null);
294294
}
295295

296+
/// <summary>
297+
/// Searches for all instance and static methods that are marked with an attribute of
298+
/// type <see cref="RouteAttribute"/> in the specified object and creates routes
299+
/// for these methods.
300+
/// </summary>
301+
/// <param name="attrClassType">The type of the class where the methods are. The routing methods must be marked with any <see cref="RouteAttribute"/>.</param>
302+
/// <param name="instance">The instance of the object where the route methods are.</param>
303+
public void SetObject([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type attrClassType, object instance)
304+
{
305+
MethodInfo[] methods = attrClassType.GetMethods(SetObjectBindingFlag);
306+
this.SetObjectInternal(methods, attrClassType, instance);
307+
}
308+
296309
/// <summary>
297310
/// Searches for all instance and static methods that are marked with an attribute of
298311
/// type <see cref="RouteAttribute"/> in the specified object and creates routes
@@ -305,6 +318,19 @@ public void SetObject([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes
305318
this.SetObject(typeof(TObject));
306319
}
307320

321+
/// <summary>
322+
/// Searches for all instance and static methods that are marked with an attribute of
323+
/// type <see cref="RouteAttribute"/> in the specified object and creates routes
324+
/// for these methods.
325+
/// </summary>
326+
/// <param name="instance">The instance of <typeparamref name="TObject"/> to invoke the instance methods on.</param>
327+
/// <typeparam name="TObject">The type of the class where the methods are. The routing methods must be marked with any <see cref="RouteAttribute"/>.</typeparam>
328+
/// <exception cref="Exception">An exception is thrown when a method has an erroneous signature.</exception>
329+
public void SetObject<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] TObject>(TObject instance) where TObject : notnull
330+
{
331+
this.SetObject(typeof(TObject), instance);
332+
}
333+
308334
private void SetObjectInternal(MethodInfo[] methods, Type callerType, object? instance)
309335
{
310336
RouterModule? rmodule = instance as RouterModule;

src/Sisk.Core.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<!-- supported frameworks -->
44
<PropertyGroup>
5-
<TargetFrameworks>net8.0</TargetFrameworks>
5+
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
66
<RootNamespace>Sisk.Core</RootNamespace>
77
<Configurations>Debug;Release</Configurations>
88
</PropertyGroup>
@@ -47,7 +47,7 @@
4747
<PropertyGroup>
4848
<AssemblyVersion>1.3.0</AssemblyVersion>
4949
<FileVersion>1.3.0</FileVersion>
50-
<Version>1.3.0-rc5</Version>
50+
<Version>1.3.0</Version>
5151
</PropertyGroup>
5252

5353
<!-- licensing, readme, signing -->

0 commit comments

Comments
 (0)