Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Breaking change with string.IndexOf(string) in .NET 5 #4273

Merged
merged 1 commit into from Feb 14, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/NLog/Config/LoggingConfiguration.cs
Expand Up @@ -834,7 +834,7 @@ internal string ExpandSimpleVariables(string input)
{
string output = input;

if (Variables.Count > 0 && output?.IndexOf("${") >= 0)
if (Variables.Count > 0 && output?.IndexOf('$') >= 0)
{
// TODO - make this case-insensitive, will probably require a different approach
var variables = Variables.ToList();
Expand Down
2 changes: 1 addition & 1 deletion src/NLog/Config/LoggingConfigurationParser.cs
Expand Up @@ -249,7 +249,7 @@ private string ExpandFilePathVariables(string internalLogFile)
if (ContainsSubStringIgnoreCase(internalLogFile, "${processdir}", out string processDirToken))
internalLogFile = internalLogFile.Replace(processDirToken, System.IO.Path.GetDirectoryName(LogFactory.CurrentAppEnvironment.CurrentProcessFilePath) + System.IO.Path.DirectorySeparatorChar.ToString());
#endif
if (internalLogFile.IndexOf("%", StringComparison.OrdinalIgnoreCase) >= 0)
if (internalLogFile.IndexOf('%') >= 0)
internalLogFile = Environment.ExpandEnvironmentVariables(internalLogFile);
#endif
return internalLogFile;
Expand Down
2 changes: 1 addition & 1 deletion src/NLog/LayoutRenderers/AppSettingLayoutRenderer2.cs
Expand Up @@ -83,7 +83,7 @@ public sealed class AppSettingLayoutRenderer2 : LayoutRenderer, IStringValueRend
protected override void InitializeLayoutRenderer()
{
string connectionStringSection = "ConnectionStrings.";
_connectionStringName = Item?.TrimStart().StartsWith(connectionStringSection, StringComparison.InvariantCultureIgnoreCase) == true ?
_connectionStringName = Item?.TrimStart().StartsWith(connectionStringSection, StringComparison.OrdinalIgnoreCase) == true ?
Item.TrimStart().Substring(connectionStringSection.Length) : null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/NLog/LayoutRenderers/RegistryLayoutRenderer.cs
Expand Up @@ -236,7 +236,7 @@ private static ParseResult ParseKey(string key)
/// <summary>
/// Aliases for the hives. See https://msdn.microsoft.com/en-us/library/ctb3kd86(v=vs.110).aspx
/// </summary>
private static readonly Dictionary<string, RegistryHive> HiveAliases = new Dictionary<string, RegistryHive>(StringComparer.InvariantCultureIgnoreCase)
private static readonly Dictionary<string, RegistryHive> HiveAliases = new Dictionary<string, RegistryHive>(StringComparer.OrdinalIgnoreCase)
{
{"HKEY_LOCAL_MACHINE", RegistryHive.LocalMachine},
{"HKLM", RegistryHive.LocalMachine},
Expand Down
4 changes: 2 additions & 2 deletions src/NLog/Targets/EventLogTarget.cs
Expand Up @@ -341,7 +341,7 @@ private void WriteEntry(string eventLogSource, string message, EventLogEntryType
else
{
var currentLogName = _eventLogWrapper.LogNameFromSourceName(eventLogSource, MachineName);
if (!currentLogName.Equals(Log, StringComparison.CurrentCultureIgnoreCase))
if (!currentLogName.Equals(Log, StringComparison.OrdinalIgnoreCase))
{
InternalLogger.Debug("EventLogTarget(Name={0}): Source {1} should be mapped to Log {2}, but EventLog.LogNameFromSourceName returns {3}", Name, eventLogSource, Log, currentLogName);
}
Expand Down Expand Up @@ -424,7 +424,7 @@ private void CreateEventSourceIfNeeded(string fixedSource, bool alwaysThrowError
if (_eventLogWrapper.SourceExists(fixedSource, MachineName))
{
string currentLogName = _eventLogWrapper.LogNameFromSourceName(fixedSource, MachineName);
if (!currentLogName.Equals(Log, StringComparison.CurrentCultureIgnoreCase))
if (!currentLogName.Equals(Log, StringComparison.OrdinalIgnoreCase))
{
InternalLogger.Debug("EventLogTarget(Name={0}): Updating source {1} to use log {2}, instead of {3} (Computer restart is needed)", Name, fixedSource, Log, currentLogName);

Expand Down