// Sample C# file for testing — SampleFiles.online
// C# source file with common language features for parser testing.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace SampleApp.Models
{
/// Represents an order in the system.
public record Order(int Id, string Customer, decimal Total, DateTime CreatedAt)
{
public string Summary => $"#{Id}: {Customer} — {Total:C}";
}
public interface IRepository where T : class
{
Task FindAsync(int id);
Task> ListAsync();
}
public sealed class OrderService
{
private readonly IRepository _repo;
private readonly ILogger _logger;
public OrderService(IRepository repo, ILogger logger)
{
_repo = repo ?? throw new ArgumentNullException(nameof(repo));
_logger = logger;
}
public async Task GetTotalRevenueAsync()
{
var orders = await _repo.ListAsync();
return orders.Sum(o => o.Total);
}
public static IEnumerable Fibonacci(int count)
{
int a = 0, b = 1;
for (int i = 0; i < count; i++)
{
yield return a;
(a, b) = (b, a + b);
}
}
}
}