internal static class Program { public static async Task Main() { await Task.CompletedTask; } } internal interface IDataService { Task GetDataAsync(string name, bool sync = false); Task GetMoreDataAsync(bool runSynchronously, string name); Task FetchAsync(int id, bool sync = false, bool cache = true); } internal class BusinessLogic(IDataService dataService) { private readonly IDataService _dataService = dataService; // ── Good patterns (no SYNC001) ────────────────────────── /// Passes the default 'sync' variable positionally. public async Task Good_ForwardSync(bool sync) { return await _dataService.GetDataAsync("Stevan", sync); } /// Passes a custom 'runSynchronously' variable positionally. public async Task Good_ForwardCustomFlag(bool runSynchronously) { return await _dataService.GetMoreDataAsync(runSynchronously, "Freeborn"); } // ── Bad patterns (SYNC001, demonstrating code fix) ────── /// Omits the sync argument entirely. /// Code fix: inserts `sync` at ordinal 1. public async Task Bad_OmittedSync(bool sync) { return await _dataService.GetDataAsync("Stevan"); } /// Hardcodes `false` as a positional argument. /// Code fix: replaces arg at ordinal 1 with `sync`. public async Task Bad_HardcodedValue(bool sync) { return await _dataService.GetDataAsync("Stevan", false); } /// Hardcodes a value using a named argument. /// Code fix: replaces expression in the named arg, keeping `sync:`. public async Task Bad_NamedHardcoded(bool sync) { return await _dataService.GetDataAsync("Stevan", sync: false); } /// Omits sync when it's not the last parameter. /// Code fix: inserts `sync` at ordinal 1 (before `cache`). public async Task Bad_OmittedSyncNotLast(bool sync) { return await _dataService.FetchAsync(17); } /// Hardcodes `false` at ordinal 0 where the target expects `runSynchronously`. /// Code fix: replaces arg at ordinal 0 with `sync` (value = enclosing name). public async Task Bad_HardcodedAtOrdinalZero(bool sync) { return await _dataService.GetMoreDataAsync(false, "Freeborn"); } }