| __`SYSLIB1021`__ | Can't have the same template with different casing |
| __`SYSLIB1022`__ | Can't have malformed format strings (like dangling {, etc) |
| __`SYSLIB1023`__ | Generating more than 6 arguments is not supported |
-| __`SYSLIB1024`__ | *_`SYSLIB1024`-`SYSLIB1029` reserved for logging._* |
+| __`SYSLIB1024`__ | Argument is using the unsupported out parameter modifier |
| __`SYSLIB1025`__ | *_`SYSLIB1024`-`SYSLIB1029` reserved for logging._* |
| __`SYSLIB1026`__ | *_`SYSLIB1024`-`SYSLIB1029` reserved for logging._* |
| __`SYSLIB1027`__ | *_`SYSLIB1024`-`SYSLIB1029` reserved for logging._* |
category: "LoggingGenerator",
DiagnosticSeverity.Error,
isEnabledByDefault: true);
+
+ public static DiagnosticDescriptor InvalidLoggingMethodParameterOut { get; } = new DiagnosticDescriptor(
+ id: "SYSLIB1024",
+ title: new LocalizableResourceString(nameof(SR.InvalidLoggingMethodParameterOutTitle), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
+ messageFormat: new LocalizableResourceString(nameof(SR.InvalidLoggingMethodParameterOutMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
+ category: "LoggingGenerator",
+ DiagnosticSeverity.Error,
+ isEnabledByDefault: true);
}
}
{
qualifier = "ref";
}
+ else if (paramSymbol.RefKind == RefKind.Out)
+ {
+ Diag(DiagnosticDescriptors.InvalidLoggingMethodParameterOut, paramSymbol.Locations[0], paramName);
+ keepMethod = false;
+ break;
+ }
+
string typeName = paramTypeSymbol.ToDisplayString(
SymbolDisplayFormat.FullyQualifiedFormat.WithMiscellaneousOptions(
SymbolDisplayMiscellaneousOptions.IncludeNullableReferenceTypeModifier));
<data name="GeneratingForMax6ArgumentsMessage" xml:space="preserve">
<value>Generating more than 6 arguments is not supported</value>
</data>
+ <data name="InvalidLoggingMethodParameterOutMessage" xml:space="preserve">
+ <value>Argument '{0}' is using the unsupported out parameter modifier</value>
+ </data>
+ <data name="InvalidLoggingMethodParameterOutTitle" xml:space="preserve">
+ <value>Argument is using the unsupported out parameter modifier</value>
+ </data>
</root>
\ No newline at end of file
<target state="translated">Názvy parametrů metody protokolování nemůžou začínat podtržítkem (_).</target>
<note />
</trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutMessage">
+ <source>Argument '{0}' is using the unsupported out parameter modifier</source>
+ <target state="new">Argument '{0}' is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutTitle">
+ <source>Argument is using the unsupported out parameter modifier</source>
+ <target state="new">Argument is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
<trans-unit id="LoggingMethodHasBodyMessage">
<source>Logging methods cannot have a body</source>
<target state="translated">Metody protokolování nemůžou obsahovat tělo.</target>
<target state="translated">Parameternamen für die Protokollierungsmethode dürfen nicht mit "_" beginnen.</target>
<note />
</trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutMessage">
+ <source>Argument '{0}' is using the unsupported out parameter modifier</source>
+ <target state="new">Argument '{0}' is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutTitle">
+ <source>Argument is using the unsupported out parameter modifier</source>
+ <target state="new">Argument is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
<trans-unit id="LoggingMethodHasBodyMessage">
<source>Logging methods cannot have a body</source>
<target state="translated">Protokollierungsmethoden dürfen keinen Text enthalten.</target>
<target state="translated">Los nombres de parámetro del método de registro no pueden empezar por _</target>
<note />
</trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutMessage">
+ <source>Argument '{0}' is using the unsupported out parameter modifier</source>
+ <target state="new">Argument '{0}' is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutTitle">
+ <source>Argument is using the unsupported out parameter modifier</source>
+ <target state="new">Argument is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
<trans-unit id="LoggingMethodHasBodyMessage">
<source>Logging methods cannot have a body</source>
<target state="translated">Los métodos de registro no pueden tener cuerpo</target>
<target state="translated">Les noms de paramètres de méthode de journalisation ne peuvent pas commencer par _</target>
<note />
</trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutMessage">
+ <source>Argument '{0}' is using the unsupported out parameter modifier</source>
+ <target state="new">Argument '{0}' is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutTitle">
+ <source>Argument is using the unsupported out parameter modifier</source>
+ <target state="new">Argument is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
<trans-unit id="LoggingMethodHasBodyMessage">
<source>Logging methods cannot have a body</source>
<target state="translated">Les méthodes de journalisation ne peuvent pas avoir de corps</target>
<target state="translated">I nomi dei parametri del metodo di registrazione non possono iniziare con _</target>
<note />
</trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutMessage">
+ <source>Argument '{0}' is using the unsupported out parameter modifier</source>
+ <target state="new">Argument '{0}' is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutTitle">
+ <source>Argument is using the unsupported out parameter modifier</source>
+ <target state="new">Argument is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
<trans-unit id="LoggingMethodHasBodyMessage">
<source>Logging methods cannot have a body</source>
<target state="translated">I metodi di registrazione non possono avere un corpo</target>
<target state="translated">Logging method パラメーター名は「 _ 」で始まることはできません</target>
<note />
</trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutMessage">
+ <source>Argument '{0}' is using the unsupported out parameter modifier</source>
+ <target state="new">Argument '{0}' is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutTitle">
+ <source>Argument is using the unsupported out parameter modifier</source>
+ <target state="new">Argument is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
<trans-unit id="LoggingMethodHasBodyMessage">
<source>Logging methods cannot have a body</source>
<target state="translated">ログ メソッドは本文を含めることができません</target>
<target state="translated">로깅 메서드 매개 변수 이름은 _로 시작할 수 없음</target>
<note />
</trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutMessage">
+ <source>Argument '{0}' is using the unsupported out parameter modifier</source>
+ <target state="new">Argument '{0}' is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutTitle">
+ <source>Argument is using the unsupported out parameter modifier</source>
+ <target state="new">Argument is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
<trans-unit id="LoggingMethodHasBodyMessage">
<source>Logging methods cannot have a body</source>
<target state="translated">로깅 메서드에는 본문을 사용할 수 없음</target>
<target state="translated">Nazwy parametrów metody rejestrowania nie mogą rozpoczynać się od znaku „_”</target>
<note />
</trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutMessage">
+ <source>Argument '{0}' is using the unsupported out parameter modifier</source>
+ <target state="new">Argument '{0}' is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutTitle">
+ <source>Argument is using the unsupported out parameter modifier</source>
+ <target state="new">Argument is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
<trans-unit id="LoggingMethodHasBodyMessage">
<source>Logging methods cannot have a body</source>
<target state="translated">Metody rejestrowania nie mogą mieć treści</target>
<target state="translated">Os nomes dos parâmetros do método de registro em log não podem começar com _</target>
<note />
</trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutMessage">
+ <source>Argument '{0}' is using the unsupported out parameter modifier</source>
+ <target state="new">Argument '{0}' is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutTitle">
+ <source>Argument is using the unsupported out parameter modifier</source>
+ <target state="new">Argument is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
<trans-unit id="LoggingMethodHasBodyMessage">
<source>Logging methods cannot have a body</source>
<target state="translated">Os métodos de registro em log não podem ter um corpo</target>
<target state="translated">Имена параметров метода ведения журнала не могут начинаться с символа "_"</target>
<note />
</trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutMessage">
+ <source>Argument '{0}' is using the unsupported out parameter modifier</source>
+ <target state="new">Argument '{0}' is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutTitle">
+ <source>Argument is using the unsupported out parameter modifier</source>
+ <target state="new">Argument is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
<trans-unit id="LoggingMethodHasBodyMessage">
<source>Logging methods cannot have a body</source>
<target state="translated">У методов ведения журнала не может быть текста</target>
<target state="translated">Günlüğe kaydetme yöntemi parametre adları _ ile başlayamaz</target>
<note />
</trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutMessage">
+ <source>Argument '{0}' is using the unsupported out parameter modifier</source>
+ <target state="new">Argument '{0}' is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutTitle">
+ <source>Argument is using the unsupported out parameter modifier</source>
+ <target state="new">Argument is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
<trans-unit id="LoggingMethodHasBodyMessage">
<source>Logging methods cannot have a body</source>
<target state="translated">Günlüğe kaydetme yöntemleri gövde içeremez</target>
<target state="translated">日志记录方法参数名称不能以 _ 开头</target>
<note />
</trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutMessage">
+ <source>Argument '{0}' is using the unsupported out parameter modifier</source>
+ <target state="new">Argument '{0}' is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutTitle">
+ <source>Argument is using the unsupported out parameter modifier</source>
+ <target state="new">Argument is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
<trans-unit id="LoggingMethodHasBodyMessage">
<source>Logging methods cannot have a body</source>
<target state="translated">日志记录方法不能有正文</target>
<target state="translated">記錄方法參數名稱的開頭不能為 _</target>
<note />
</trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutMessage">
+ <source>Argument '{0}' is using the unsupported out parameter modifier</source>
+ <target state="new">Argument '{0}' is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="InvalidLoggingMethodParameterOutTitle">
+ <source>Argument is using the unsupported out parameter modifier</source>
+ <target state="new">Argument is using the unsupported out parameter modifier</target>
+ <note />
+ </trans-unit>
<trans-unit id="LoggingMethodHasBodyMessage">
<source>Logging methods cannot have a body</source>
<target state="translated">記錄方法不能有主體</target>
}
[Fact]
+ public async Task InvalidRefKindsOut()
+ {
+ IReadOnlyList<Diagnostic> diagnostics = await RunGenerator(@$"
+ partial class C
+ {{
+ [LoggerMessage(EventId = 0, Level = LogLevel.Debug, Message = ""Parameter {{P1}}"")]
+ static partial void M(ILogger logger, out int p1);
+ }}");
+
+ Assert.Single(diagnostics);
+ Assert.Equal(DiagnosticDescriptors.InvalidLoggingMethodParameterOut.Id, diagnostics[0].Id);
+ Assert.Contains("p1", diagnostics[0].GetMessage(), StringComparison.InvariantCulture);
+ }
+
+ [Fact]
public async Task Templates()
{
IReadOnlyList<Diagnostic> diagnostics = await RunGenerator(@"