forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Supports usage of "in" modifier - Improves support for generic constraints Fixes dotnet#58550, dotnet#62644
- Loading branch information
1 parent
58db8db
commit be3a808
Showing
8 changed files
with
210 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
...sts/Microsoft.Extensions.Logging.Generators.Tests/TestClasses/ConstaintsTestExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Microsoft.Extensions.Logging.Generators.Tests.TestClasses | ||
{ | ||
using ConstraintInAnotherNamespace; | ||
namespace UsesConstraintInAnotherNamespace | ||
{ | ||
public partial class MessagePrinter<T> | ||
where T : Message | ||
{ | ||
public void Print(ILogger logger, T message) | ||
{ | ||
Log.Message(logger, message.Text); | ||
} | ||
|
||
internal static partial class Log | ||
{ | ||
[LoggerMessage(EventId = 1, Level = LogLevel.Information, Message = "The message is {Text}.")] | ||
internal static partial void Message(ILogger logger, string? text); | ||
} | ||
} | ||
} | ||
|
||
internal static partial class ConstraintsTestExtensions<T> | ||
where T : class | ||
{ | ||
[LoggerMessage(EventId = 0, Level = LogLevel.Debug, Message = "M0{p0}")] | ||
public static partial void M0(ILogger logger, int p0); | ||
|
||
public static void Foo(T dummy) | ||
{ | ||
} | ||
} | ||
|
||
internal static partial class ConstraintsTestExtensions1<T> | ||
where T : struct | ||
{ | ||
[LoggerMessage(EventId = 0, Level = LogLevel.Debug, Message = "M0{p0}")] | ||
public static partial void M0(ILogger logger, int p0); | ||
|
||
public static void Foo(T dummy) | ||
{ | ||
} | ||
} | ||
|
||
internal static partial class ConstraintsTestExtensions2<T> | ||
where T : unmanaged | ||
{ | ||
[LoggerMessage(EventId = 0, Level = LogLevel.Debug, Message = "M0{p0}")] | ||
public static partial void M0(ILogger logger, int p0); | ||
|
||
public static void Foo(T dummy) | ||
{ | ||
} | ||
} | ||
|
||
internal static partial class ConstraintsTestExtensions3<T> | ||
where T : new() | ||
{ | ||
[LoggerMessage(EventId = 0, Level = LogLevel.Debug, Message = "M0{p0}")] | ||
public static partial void M0(ILogger logger, int p0); | ||
|
||
public static void Foo(T dummy) | ||
{ | ||
} | ||
} | ||
|
||
internal static partial class ConstraintsTestExtensions4<T> | ||
where T : System.Attribute | ||
{ | ||
[LoggerMessage(EventId = 0, Level = LogLevel.Debug, Message = "M0{p0}")] | ||
public static partial void M0(ILogger logger, int p0); | ||
|
||
public static void Foo(T dummy) | ||
{ | ||
} | ||
} | ||
|
||
internal static partial class ConstraintsTestExtensions5<T> | ||
where T : notnull | ||
{ | ||
[LoggerMessage(EventId = 0, Level = LogLevel.Debug, Message = "M0{p0}")] | ||
public static partial void M0(ILogger logger, int p0); | ||
|
||
public static void Foo(T dummy) | ||
{ | ||
} | ||
} | ||
} | ||
|
||
namespace ConstraintInAnotherNamespace | ||
{ | ||
public class Message | ||
{ | ||
public string? Text { get; set; } | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ts/Microsoft.Extensions.Logging.Generators.Tests/TestClasses/InParameterTestExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Microsoft.Extensions.Logging.Generators.Tests.TestClasses | ||
{ | ||
internal static partial class InParameterTestExtensions | ||
{ | ||
internal struct S | ||
{ | ||
public override string ToString() => "Hello from S"; | ||
} | ||
|
||
[LoggerMessage(EventId = 0, Level = LogLevel.Information, Message = "M0 {s}")] | ||
internal static partial void M0(ILogger logger, in S s); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters