Skip to content

Commit

Permalink
fixed issue of setting static state by constructor when overriding fo…
Browse files Browse the repository at this point in the history
…rmating options
  • Loading branch information
adrianoc committed Oct 9, 2021
1 parent 309c8fc commit 9c56b62
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Cecilifier.Core/Naming/DefaultNameStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Cecilifier.Core.Naming
{
public class DefaultNameStrategy : INameStrategy
{
private static IReadOnlyDictionary<ElementKind, string> _format = new Dictionary<ElementKind, string>
private static IReadOnlyDictionary<ElementKind, string> _defaultFormat = new Dictionary<ElementKind, string>
{
[ElementKind.Attribute] = "attr",
[ElementKind.Class] = "cls",
Expand All @@ -32,11 +32,17 @@ public class DefaultNameStrategy : INameStrategy
[ElementKind.IL] = "il",
};

public DefaultNameStrategy() => Options = NamingOptions.All;

private IReadOnlyDictionary<ElementKind, string> _format;

public DefaultNameStrategy()
{
Options = NamingOptions.All;
_format = _defaultFormat;
}

public DefaultNameStrategy(NamingOptions namingOptions, IReadOnlyDictionary<ElementKind, string> format)
{
_format = format;
_format = format ?? _defaultFormat;
Options = namingOptions;
}

Expand Down

0 comments on commit 9c56b62

Please sign in to comment.