mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-13 11:27:21 +00:00
Renamed the extension classes of interfaces to drop the I prefix (#1190)
This commit is contained in:
1 parent
d8ef328e6e
commit
6f187f1bd8
30 files changed
+59
-59
No files matched your search
@@ -21,7 +21,7 @@ public sealed class DirectI18NGetTextAnalyzerTests
|
||||
{
|
||||
private const string CLASSIC_FORM =
|
||||
"""
|
||||
public static class ILangExtensions
|
||||
public static class LangExtensions
|
||||
{
|
||||
public static string GetText(this ILang lang, string fallbackEN) => fallbackEN;
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public sealed class DirectI18NGetTextAnalyzerTests
|
||||
|
||||
private const string EXTENSION_BLOCK_FORM =
|
||||
"""
|
||||
public static class ILangExtensions
|
||||
public static class LangExtensions
|
||||
{
|
||||
extension(ILang lang)
|
||||
{
|
||||
@@ -52,11 +52,11 @@ public sealed class DirectI18NGetTextAnalyzerTests
|
||||
|
||||
[TestCase(CLASSIC_FORM, """public string Describe() => this.GetText("Hello");""", TestName = "A classic extension method called from another method")]
|
||||
[TestCase(CLASSIC_FORM, """public string T(string fallbackEN) => this.GetText("Hello");""", TestName = "A classic extension method called by a wrapper with a text of its own")]
|
||||
[TestCase(CLASSIC_FORM, """public string Describe() => ILangExtensions.GetText(this, "Hello");""", TestName = "A classic extension method called as a static method")]
|
||||
[TestCase(CLASSIC_FORM, """public string Describe() => LangExtensions.GetText(this, "Hello");""", TestName = "A classic extension method called as a static method")]
|
||||
[TestCase(EXTENSION_BLOCK_FORM, """public string Describe() => this.GetText("Hello");""", TestName = "The member of an extension block called from another method")]
|
||||
[TestCase(EXTENSION_BLOCK_FORM, """public string T(string fallbackEN) => this.GetText("Hello");""", TestName = "The member of an extension block called by a wrapper with a text of its own")]
|
||||
[TestCase(EXTENSION_BLOCK_FORM, """public string TA(string fallbackEN) => this.GetText("Hello");""", TestName = "The member of an extension block called by a TA wrapper with a text of its own")]
|
||||
[TestCase(EXTENSION_BLOCK_FORM, """public string Describe() => ILangExtensions.GetText(this, "Hello");""", TestName = "The member of an extension block called as a static method")]
|
||||
[TestCase(EXTENSION_BLOCK_FORM, """public string Describe() => LangExtensions.GetText(this, "Hello");""", TestName = "The member of an extension block called as a static method")]
|
||||
public async Task ADirectLookupIsRefused(string form, string member)
|
||||
{
|
||||
var reported = await AnalyzeAsync(form, member);
|
||||
@@ -99,7 +99,7 @@ public sealed class DirectI18NGetTextAnalyzerTests
|
||||
private static async Task<IReadOnlyList<Diagnostic>> AnalyzeAsync(string form, string member)
|
||||
{
|
||||
//
|
||||
// The snippet declares its own ILang and ILangExtensions where the analyzer looks for them. They take
|
||||
// The snippet declares its own ILang and LangExtensions where the analyzer looks for them. They take
|
||||
// the place of those of the app, which the compilation references as well.
|
||||
//
|
||||
var source =
|
||||
|
||||
@@ -75,7 +75,7 @@ public sealed class BflImageMaterialTests
|
||||
Assert.That(await File.ReadAllBytesAsync(copy), Is.EqualTo(Convert.FromBase64String(FakeImageRuntime.IMAGE_BASE64)));
|
||||
Assert.That(copy, Does.StartWith(Path.Combine(this.dataDirectory, BeyondFactsLabStore.ROOT_DIRECTORY_NAME)), "The material must not depend on the file of the person.");
|
||||
Assert.That(this.runtime.RequestedPaths, Is.EqualTo(new[] { poster }));
|
||||
Assert.That(this.runtime.RequestedBudgets, Is.EqualTo(new[] { IImageSourceExtensions.MAX_IMAGE_SIZE_BYTES }), "The copy must be as large as any provider takes.");
|
||||
Assert.That(this.runtime.RequestedBudgets, Is.EqualTo(new[] { ImageSourceExtensions.MAX_IMAGE_SIZE_BYTES }), "The copy must be as large as any provider takes.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ namespace AIStudio.Tests.Chat;
|
||||
/// way the one can run into the other -- an open code fence above all. A document has no such seam.
|
||||
/// </remarks>
|
||||
[TestFixture]
|
||||
public sealed class IContentExtensionsTests
|
||||
public sealed class ContentExtensionsTests
|
||||
{
|
||||
private static readonly Source TOOL_SOURCE = new("Search result", "https://example.org/search", SourceOrigin.TOOL);
|
||||
|
||||
@@ -20,7 +20,7 @@ public sealed class ImageSizeLimitTests
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(LLMProviders.ANTHROPIC.MaxImageSizeBytes, Is.EqualTo(3_932_160));
|
||||
Assert.That(IImageSourceExtensions.MaxImageSizeBytesFor(ProviderOf(LLMProviders.ANTHROPIC)), Is.EqualTo(3_932_160));
|
||||
Assert.That(ImageSourceExtensions.MaxImageSizeBytesFor(ProviderOf(LLMProviders.ANTHROPIC)), Is.EqualTo(3_932_160));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public sealed class ImageSizeLimitTests
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(LLMProviders.OPEN_AI.MaxImageSizeBytes, Is.Null, "Nobody stated a limit, and no number stands in for that.");
|
||||
Assert.That(IImageSourceExtensions.MaxImageSizeBytesFor(ProviderOf(LLMProviders.OPEN_AI)), Is.EqualTo(IImageSourceExtensions.MAX_IMAGE_SIZE_BYTES));
|
||||
Assert.That(ImageSourceExtensions.MaxImageSizeBytesFor(ProviderOf(LLMProviders.OPEN_AI)), Is.EqualTo(ImageSourceExtensions.MAX_IMAGE_SIZE_BYTES));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ public sealed class ImageSizeLimitTests
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(Host.LLMMAN.MaxImageSizeBytes, Is.EqualTo(1_048_576));
|
||||
Assert.That(IImageSourceExtensions.MaxImageSizeBytesFor(ProviderOf(LLMProviders.SELF_HOSTED, Host.LLMMAN)), Is.EqualTo(1_048_576));
|
||||
Assert.That(IImageSourceExtensions.MaxImageSizeBytesFor(ProviderOf(LLMProviders.SELF_HOSTED, Host.OLLAMA)), Is.EqualTo(IImageSourceExtensions.MAX_IMAGE_SIZE_BYTES), "Ollama states no limit we know of.");
|
||||
Assert.That(ImageSourceExtensions.MaxImageSizeBytesFor(ProviderOf(LLMProviders.SELF_HOSTED, Host.LLMMAN)), Is.EqualTo(1_048_576));
|
||||
Assert.That(ImageSourceExtensions.MaxImageSizeBytesFor(ProviderOf(LLMProviders.SELF_HOSTED, Host.OLLAMA)), Is.EqualTo(ImageSourceExtensions.MAX_IMAGE_SIZE_BYTES), "Ollama states no limit we know of.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public sealed class ImageSizeLimitTests
|
||||
// to a cloud provider in the dialog:
|
||||
var cloudProviderWithAnOldHost = ProviderOf(LLMProviders.OPEN_AI, Host.LLMMAN);
|
||||
|
||||
Assert.That(IImageSourceExtensions.MaxImageSizeBytesFor(cloudProviderWithAnOldHost), Is.EqualTo(IImageSourceExtensions.MAX_IMAGE_SIZE_BYTES));
|
||||
Assert.That(ImageSourceExtensions.MaxImageSizeBytesFor(cloudProviderWithAnOldHost), Is.EqualTo(ImageSourceExtensions.MAX_IMAGE_SIZE_BYTES));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -62,7 +62,7 @@ public sealed class ImageSizeLimitTests
|
||||
{
|
||||
foreach (var llmProvider in Enum.GetValues<LLMProviders>())
|
||||
foreach (var host in Enum.GetValues<Host>())
|
||||
Assert.That(IImageSourceExtensions.MaxImageSizeBytesFor(ProviderOf(llmProvider, host)), Is.LessThanOrEqualTo(IImageSourceExtensions.MAX_IMAGE_SIZE_BYTES), $"{llmProvider} with {host}");
|
||||
Assert.That(ImageSourceExtensions.MaxImageSizeBytesFor(ProviderOf(llmProvider, host)), Is.LessThanOrEqualTo(ImageSourceExtensions.MAX_IMAGE_SIZE_BYTES), $"{llmProvider} with {host}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ public sealed class ModelImageServiceTests
|
||||
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(this.runtime.RequestedBudgets, Is.EqualTo(new[] { 3_932_160, IImageSourceExtensions.MAX_IMAGE_SIZE_BYTES }));
|
||||
Assert.That(this.runtime.RequestedBudgets, Is.EqualTo(new[] { 3_932_160, ImageSourceExtensions.MAX_IMAGE_SIZE_BYTES }));
|
||||
Assert.That(this.runtime.RequestedPaths, Is.All.EqualTo(new FileInfo(this.imagePath).FullName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,8 +144,8 @@ public sealed class RetrievalContextDescriptionTests
|
||||
};
|
||||
|
||||
var builder = new StringBuilder();
|
||||
IRetrievalContextExtensions.AppendContextDescription(builder, image);
|
||||
IRetrievalContextExtensions.AppendImageMatch(builder);
|
||||
RetrievalContextExtensions.AppendContextDescription(builder, image);
|
||||
RetrievalContextExtensions.AppendImageMatch(builder);
|
||||
var description = builder.ToString();
|
||||
|
||||
using (Assert.EnterMultipleScope())
|
||||
@@ -161,7 +161,7 @@ public sealed class RetrievalContextDescriptionTests
|
||||
private static string Describe(IRetrievalContext retrievalContext)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
IRetrievalContextExtensions.AppendContextDescription(builder, retrievalContext);
|
||||
RetrievalContextExtensions.AppendContextDescription(builder, retrievalContext);
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
|
||||
@@ -120,8 +120,8 @@ public sealed class RetrievalContextPreparationTests
|
||||
|
||||
var expected = new StringBuilder();
|
||||
expected.AppendLine("# Retrieval context");
|
||||
IRetrievalContextExtensions.AppendContextDescription(expected, image);
|
||||
IRetrievalContextExtensions.AppendImageMatch(expected);
|
||||
RetrievalContextExtensions.AppendContextDescription(expected, image);
|
||||
RetrievalContextExtensions.AppendImageMatch(expected);
|
||||
expected.AppendLine();
|
||||
|
||||
using (Assert.EnterMultipleScope())
|
||||
|
||||
@@ -22,37 +22,37 @@ public sealed class RetrievalContextShorteningTests
|
||||
{
|
||||
const string TEXT = "first line\nsecond line";
|
||||
|
||||
Assert.That(IRetrievalContextExtensions.CutAtLineEnd(TEXT, TEXT.Length), Is.SameAs(TEXT));
|
||||
Assert.That(RetrievalContextExtensions.CutAtLineEnd(TEXT, TEXT.Length), Is.SameAs(TEXT));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ACutEndsAtTheLastLineEndWhichFits()
|
||||
{
|
||||
Assert.That(IRetrievalContextExtensions.CutAtLineEnd("first\nsecond\nthird", 15), Is.EqualTo("first\nsecond"));
|
||||
Assert.That(RetrievalContextExtensions.CutAtLineEnd("first\nsecond\nthird", 15), Is.EqualTo("first\nsecond"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ACutKeepsNoHalfOfAWindowsLineEnd()
|
||||
{
|
||||
Assert.That(IRetrievalContextExtensions.CutAtLineEnd("first\r\nsecond\r\nthird", 17), Is.EqualTo("first\r\nsecond"));
|
||||
Assert.That(RetrievalContextExtensions.CutAtLineEnd("first\r\nsecond\r\nthird", 17), Is.EqualTo("first\r\nsecond"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ACutGivesUpAtMostHalfOfWhatFitsForALineEnd()
|
||||
{
|
||||
Assert.That(IRetrievalContextExtensions.CutAtLineEnd("a\nbcdefghijkl", 10), Is.EqualTo("a\nbcdefghi"), "With its only line end right at the start, the text would lose nearly everything.");
|
||||
Assert.That(RetrievalContextExtensions.CutAtLineEnd("a\nbcdefghijkl", 10), Is.EqualTo("a\nbcdefghi"), "With its only line end right at the start, the text would lose nearly everything.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ACutNeverSplitsASurrogatePair()
|
||||
{
|
||||
Assert.That(IRetrievalContextExtensions.CutAtLineEnd("ab😀cd", 3), Is.EqualTo("ab"));
|
||||
Assert.That(RetrievalContextExtensions.CutAtLineEnd("ab😀cd", 3), Is.EqualTo("ab"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NothingIsLeftOfATextWithoutRoom()
|
||||
{
|
||||
Assert.That(IRetrievalContextExtensions.CutAtLineEnd("text", 0), Is.Empty);
|
||||
Assert.That(RetrievalContextExtensions.CutAtLineEnd("text", 0), Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in new issue
Block a user