C#: Enhanced LogForgingQuery to treat C# Enums as simple types.

This commit is contained in:
Ian Roof
2024-09-26 16:56:41 -04:00
committed by Michael Nebel
parent 45b55c05ae
commit 1d81c77fcd
3 changed files with 52 additions and 1 deletions

View File

@@ -0,0 +1,46 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Web;
using Microsoft.Extensions.Logging;
class ILogger
{
public void Warn(string message) { }
}
enum TestEnum
{
TestEnumValue
}
public class LogForgingSimpleTypes
{
public void Execute(HttpContext ctx)
{
// GOOD: int
logger.Warn("Logging simple type (int):" 1);
// GOOD: long
logger.Warn("Logging simple type (int):" 1L);
// GOOD: float
logger.Warn("Logging simple type (float):" 1.1);
// GOOD: double
logger.Warn("Logging simple type (double):" 1.1d);
// GOOD: decimal
logger.Warn("Logging simple type (double):" 1.1m);
// GOOD: Enum
logger.Warn("Logging simple type (Enum):" TestEnum.TestEnumVAlue);
// GOOD: DateTime
logger.Warn("Logging simple type (int):" new DateTime());
// GOOD: DateTimeOffset
logger.Warn("Logging simple type (int):" DateTimeOffset.UtcNow);
}
}