mirror of
https://github.com/dotnet/skills.git
synced 2026-09-20 09:49:54 +08:00
7e6954f9a9
* Add testability migration skills and agent for dotnet-test Introduces three skills and one orchestrator agent to help developers incrementally replace hard-to-test static dependencies with injectable abstractions: - detect-static-dependencies: scans C# code for DateTime.Now, File.*, Environment.*, HttpClient, Console.*, Process.* and ranks by frequency - generate-testability-wrappers: generates wrapper interfaces or guides adoption of built-in abstractions (TimeProvider, IHttpClientFactory, System.IO.Abstractions) - migrate-static-to-wrapper: mechanical codemod-style bulk replacement of static call sites with wrapper calls, scoped per project/namespace - testability-migration agent: orchestrates the Detect-Generate-Migrate pipeline end-to-end Includes eval.yaml tests and fixture projects for all three skills and the agent. * Fix activation, token overhead, and eval timeouts - Expand skill descriptions with more trigger phrases for migrate-static-to-wrapper and generate-testability-wrappers to fix NOT ACTIVATED issues - Collapse verbose replacement mapping tables and constructor examples to reduce token overhead (~30% fewer tokens) - Increase generate-testability-wrappers eval timeouts from 120s to 240s to prevent timeout-impacted scoring - Soften detect-static-dependencies scenario 2 rubric to reduce run-to-run variance in plugin mode - Increase migrate-static-to-wrapper non-activation timeout
42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
namespace FullPipeline.Services;
|
|
|
|
public class SubscriptionManager
|
|
{
|
|
public Subscription CreateTrial(string userId)
|
|
{
|
|
return new Subscription
|
|
{
|
|
UserId = userId,
|
|
StartedAt = DateTime.UtcNow,
|
|
ExpiresAt = DateTime.UtcNow.AddDays(14),
|
|
Plan = "trial"
|
|
};
|
|
}
|
|
|
|
public bool IsActive(Subscription sub)
|
|
{
|
|
return DateTime.UtcNow < sub.ExpiresAt;
|
|
}
|
|
|
|
public void ExportSubscription(Subscription sub)
|
|
{
|
|
var exportDir = Environment.GetEnvironmentVariable("EXPORT_DIR") ?? "/tmp/exports";
|
|
if (!Directory.Exists(exportDir))
|
|
{
|
|
Directory.CreateDirectory(exportDir);
|
|
}
|
|
|
|
var json = System.Text.Json.JsonSerializer.Serialize(sub);
|
|
File.WriteAllText(Path.Combine(exportDir, $"{sub.UserId}.json"), json);
|
|
Console.WriteLine($"Exported subscription for {sub.UserId}");
|
|
}
|
|
}
|
|
|
|
public class Subscription
|
|
{
|
|
public string UserId { get; set; } = "";
|
|
public DateTime StartedAt { get; set; }
|
|
public DateTime ExpiresAt { get; set; }
|
|
public string Plan { get; set; } = "";
|
|
}
|