-
-
Notifications
You must be signed in to change notification settings - Fork 163
Expand file tree
/
Copy pathFullControllerInfo.cs
More file actions
29 lines (25 loc) · 1.55 KB
/
FullControllerInfo.cs
File metadata and controls
29 lines (25 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
namespace JsonApiDotNetCore.SourceGenerators;
/// <summary>
/// Supplemental information that is derived from the core analysis, which is expensive to produce.
/// </summary>
internal readonly record struct FullControllerInfo(
CoreControllerInfo CoreController, TypeInfo ControllerType, TypeInfo LoggerFactoryInterface, string HintFileName)
{
// Using readonly fields, so they can be passed by reference (using 'in' modifier, to avoid making copies) during code generation.
public readonly CoreControllerInfo CoreController = CoreController;
public readonly TypeInfo ControllerType = ControllerType;
public readonly TypeInfo LoggerFactoryInterface = LoggerFactoryInterface;
public readonly string HintFileName = HintFileName;
public static FullControllerInfo Create(CoreControllerInfo coreController, string controllerTypeName)
{
var controllerTypeInfo = new TypeInfo(coreController.ControllerNamespace, controllerTypeName);
var loggerFactoryTypeInfo = new TypeInfo("Microsoft.Extensions.Logging", "ILoggerFactory");
return new FullControllerInfo(coreController, controllerTypeInfo, loggerFactoryTypeInfo, controllerTypeName);
}
public FullControllerInfo WithHintFileName(string hintFileName)
{
// ReSharper disable once UseWithExpressionToCopyRecord
// Justification: Workaround for bug at https://youtrack.jetbrains.com/issue/RSRP-502017/Invalid-suggestion-to-use-with-expression.
return new FullControllerInfo(CoreController, ControllerType, LoggerFactoryInterface, hintFileName);
}
}