diff --git a/src/Verify/Verifier/InnerVerifier.cs b/src/Verify/Verifier/InnerVerifier.cs index 9882d43419..8a805efdff 100644 --- a/src/Verify/Verifier/InnerVerifier.cs +++ b/src/Verify/Verifier/InnerVerifier.cs @@ -48,15 +48,8 @@ public InnerVerifier( var namer = settings.Namer; directory = ResolveDirectory(sourceFile, settings, pathInfo); - counter = Counter.Start( -#if NET6_0_OR_GREATER - settings.namedDates, - settings.namedTimes, -#endif - settings.namedDateTimes, - settings.namedGuids, - settings.namedDateTimeOffsets - ); + + counter = StartCounter(settings); IoHelpers.CreateDirectory(directory); @@ -82,31 +75,39 @@ public InnerVerifier(string sourceFile, VerifySettings settings) this.settings = settings; directory = ResolveDirectory(sourceFile, settings, new()); - counter = Counter.Start( -#if NET6_0_OR_GREATER - settings.namedDates, - settings.namedTimes, -#endif - settings.namedDateTimes, - settings.namedGuids, - settings.namedDateTimeOffsets - ); + counter = StartCounter(settings); IoHelpers.CreateDirectory(directory); ValidatePrefix(settings, directory); - verifiedFiles = new List { Path.Combine(directory, $"{Path.GetFileNameWithoutExtension(sourceFile)}.verified.{FileExtensions.GetExtension(sourceFile)}") }; + var withoutExtension = Path.GetFileNameWithoutExtension(sourceFile); + verifiedFiles = new List + { + Path.Combine(directory, $"{withoutExtension}.verified.{FileExtensions.GetExtension(sourceFile)}") + }; - getFileNames = target => new( - target.Extension, - sourceFile, - Path.Combine(directory, $"{Path.GetFileNameWithoutExtension(sourceFile)}.verified.{target.Extension}") - ); + getFileNames = target => + new( + target.Extension, + sourceFile, + Path.Combine(directory, $"{withoutExtension}.verified.{target.Extension}") + ); getIndexedFileNames = (_, _) => throw new NotImplementedException(); } + static Counter StartCounter(VerifySettings settings) => + Counter.Start( +#if NET6_0_OR_GREATER + settings.namedDates, + settings.namedTimes, +#endif + settings.namedDateTimes, + settings.namedGuids, + settings.namedDateTimeOffsets + ); + void InitForDirectoryConvention(Namer namer, string typeAndMethod, string parameters) { var verifiedPrefix = PrefixForDirectoryConvention(namer, typeAndMethod, parameters);