Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/project/list-of-diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ The diagnostic id values reserved for .NET Libraries analyzer warnings are `SYSL
| __`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._* |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,13 @@ public static class DiagnosticDescriptors
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,13 @@ public IReadOnlyList<LoggerClass> GetLogClasses(IEnumerable<ClassDeclarationSynt
{
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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,10 @@
<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>
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,21 @@ partial class C
Assert.Empty(diagnostics);
}

[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()
{
Expand Down