Turned getter-like extension methods into extension properties (#1157)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-11-04 13:00:56 +01:00
1 parent 0375318b1b
commit f649febf88
286 files changed
+1379 -1109

No files matched your search

@@ -25,7 +25,7 @@ public sealed class AssistantPluginAuditService(AssistantAuditAgent auditAgent)
AuditProviderName = provider == Settings.Provider.NONE
? string.Empty
: provider.InstanceName,
Level = AssistantAuditLevelExtensions.Parse(result.Level),
Level = AssistantAuditLevel.ParseOrUnknown(result.Level),
Summary = result.Summary,
Confidence = result.Confidence,
PromptPreview = promptPreview,
@@ -6,7 +6,7 @@ public static class AssistantComponentTypeExtensions
extension(AssistantComponentType type)
{
public string GetDisplayName() => type switch
public string DisplayName => type switch
{
AssistantComponentType.FORM => TB("Root"),
AssistantComponentType.TEXT_AREA => TB("Text Area"),
@@ -36,7 +36,7 @@ public static class AssistantComponentTypeExtensions
_ => TB("Unknown Element")
};
public string GetIcon() => type switch
public string Icon => type switch
{
AssistantComponentType.BUTTON => MudBlazor.Icons.Material.Filled.AdsClick,
AssistantComponentType.BUTTON_GROUP => MudBlazor.Icons.Material.Filled.LinearScale,
@@ -105,8 +105,8 @@ public static class PluginAssistantSecurityResolver
CanActivatePlugin = true,
CanStartAssistant = true,
AuditLabel = TB("Safe"),
AuditColor = AssistantAuditLevel.SAFE.GetColor(),
AuditIcon = AssistantAuditLevel.SAFE.GetIcon(),
AuditColor = AssistantAuditLevel.SAFE.Color,
AuditIcon = AssistantAuditLevel.SAFE.Icon,
AvailabilityLabel = GetAvailabilityLabel(requiresAudit: false, hasAudit: true, hasHashMismatch: false, isBlocked: false, canOverride: false),
AvailabilityColor = GetAvailabilityColor(requiresAudit: false, hasAudit: true, hasHashMismatch: false, isBlocked: false, canOverride: false),
AvailabilityIcon = GetAvailabilityIcon(requiresAudit: false, hasAudit: true, hasHashMismatch: false, isBlocked: false, canOverride: false),
@@ -153,8 +153,8 @@ public static class PluginAssistantSecurityResolver
CanActivatePlugin = !isBlocked,
CanStartAssistant = !isBlocked,
AuditLabel = TB("Unknown"),
AuditColor = AssistantAuditLevel.UNKNOWN.GetColor(),
AuditIcon = AssistantAuditLevel.UNKNOWN.GetIcon(),
AuditColor = AssistantAuditLevel.UNKNOWN.Color,
AuditIcon = AssistantAuditLevel.UNKNOWN.Icon,
AvailabilityLabel = GetAvailabilityLabel(requiresAudit, hasAudit, hasHashMismatch, isBlocked, canOverride: false),
AvailabilityColor = GetAvailabilityColor(requiresAudit, hasAudit, hasHashMismatch, isBlocked, canOverride: false),
AvailabilityIcon = GetAvailabilityIcon(requiresAudit, hasAudit, hasHashMismatch, isBlocked, canOverride: false),
@@ -192,8 +192,8 @@ public static class PluginAssistantSecurityResolver
CanActivatePlugin = !isBlocked,
CanStartAssistant = !isBlocked,
AuditLabel = TB("Unknown"),
AuditColor = AssistantAuditLevel.UNKNOWN.GetColor(),
AuditIcon = AssistantAuditLevel.UNKNOWN.GetIcon(),
AuditColor = AssistantAuditLevel.UNKNOWN.Color,
AuditIcon = AssistantAuditLevel.UNKNOWN.Icon,
AvailabilityLabel = GetAvailabilityLabel(requiresAudit, hasAudit, hasHashMismatch, isBlocked, canOverride: false),
AvailabilityColor = GetAvailabilityColor(requiresAudit, hasAudit, hasHashMismatch, isBlocked, canOverride: false),
AvailabilityIcon = GetAvailabilityIcon(requiresAudit, hasAudit, hasHashMismatch, isBlocked, canOverride: false),
@@ -233,15 +233,15 @@ public static class PluginAssistantSecurityResolver
CanOverride = !isBlockedByMinimum,
CanActivatePlugin = !isBlockedByMinimum,
CanStartAssistant = !isBlockedByMinimum,
AuditLabel = auditLevel.GetName(),
AuditColor = auditLevel.GetColor(),
AuditIcon = auditLevel.GetIcon(),
AuditLabel = auditLevel.Name,
AuditColor = auditLevel.Color,
AuditIcon = auditLevel.Icon,
AvailabilityLabel = GetAvailabilityLabel(requiresAudit: false, hasAudit, hasHashMismatch: false, isBlockedByMinimum, canOverride),
AvailabilityColor = GetAvailabilityColor(requiresAudit: false, hasAudit, hasHashMismatch: false, isBlockedByMinimum, canOverride),
AvailabilityIcon = GetAvailabilityIcon(requiresAudit: false, hasAudit, hasHashMismatch: false, isBlockedByMinimum, canOverride),
StatusLabel = GetAvailabilityLabel(requiresAudit: false, hasAudit, hasHashMismatch: false, isBlockedByMinimum, canOverride),
SourceLabel = TB("User Audit"),
SourceColor = auditLevel.GetColor(),
SourceColor = auditLevel.Color,
SourceIcon = MudBlazor.Icons.Material.Filled.Verified,
BadgeIcon = GetSecurityBadgeIcon(requiresAudit: false, hasAudit, hasHashMismatch: false, isBlockedByMinimum, canOverride),
Headline = isBlockedByMinimum
@@ -250,10 +250,10 @@ public static class PluginAssistantSecurityResolver
? TB("This assistant can still be used because audit enforcement is disabled.")
: TB("This assistant can still be used because your settings allow it."),
Description = isBlockedByMinimum
? string.Format(TB("The current audit result '{0}' is below your required minimum level '{1}'. Your security settings therefore block this assistant plugin."), auditLevel.GetName(), auditSettings.MinimumLevel.GetName())
? string.Format(TB("The current audit result '{0}' is below your required minimum level '{1}'. Your security settings therefore block this assistant plugin."), auditLevel.Name, auditSettings.MinimumLevel.Name)
: isEnforcementDisabled
? string.Format(TB("The current audit result is '{0}', which is below your required minimum level '{1}'. Audit enforcement is currently disabled, so this assistant plugin can still be enabled or used."), auditLevel.GetName(), auditSettings.MinimumLevel.GetName())
: string.Format(TB("The current audit result is '{0}', which is below your required minimum level '{1}'. Your settings still allow manual activation, but the assistant keeps this security status and should be reviewed carefully."), auditLevel.GetName(), auditSettings.MinimumLevel.GetName()),
? string.Format(TB("The current audit result is '{0}', which is below your required minimum level '{1}'. Audit enforcement is currently disabled, so this assistant plugin can still be enabled or used."), auditLevel.Name, auditSettings.MinimumLevel.Name)
: string.Format(TB("The current audit result is '{0}', which is below your required minimum level '{1}'. Your settings still allow manual activation, but the assistant keeps this security status and should be reviewed carefully."), auditLevel.Name, auditSettings.MinimumLevel.Name),
StatusColor = GetAvailabilityColor(requiresAudit: false, hasAudit, hasHashMismatch: false, isBlockedByMinimum, canOverride),
StatusIcon = GetAvailabilityIcon(requiresAudit: false, hasAudit, hasHashMismatch: false, isBlockedByMinimum, canOverride),
ActionLabel = TB("Open Security Check"),
@@ -278,19 +278,19 @@ public static class PluginAssistantSecurityResolver
CanOverride = false,
CanActivatePlugin = canUsePlugin,
CanStartAssistant = canUsePlugin,
AuditLabel = auditLevelDefault.GetName(),
AuditColor = auditLevelDefault.GetColor(),
AuditIcon = auditLevelDefault.GetIcon(),
AuditLabel = auditLevelDefault.Name,
AuditColor = auditLevelDefault.Color,
AuditIcon = auditLevelDefault.Icon,
AvailabilityLabel = GetAvailabilityLabel(requiresAudit: false, hasAudit, hasHashMismatch: false, isBlocked: false, canOverride: false),
AvailabilityColor = GetAvailabilityColor(requiresAudit: false, hasAudit, hasHashMismatch: false, isBlocked: false, canOverride: false),
AvailabilityIcon = GetAvailabilityIcon(requiresAudit: false, hasAudit, hasHashMismatch: false, isBlocked: false, canOverride: false),
StatusLabel = GetAvailabilityLabel(requiresAudit: false, hasAudit, hasHashMismatch: false, isBlocked: false, canOverride: false),
SourceLabel = TB("User Audit"),
SourceColor = auditLevelDefault.GetColor(),
SourceColor = auditLevelDefault.Color,
SourceIcon = MudBlazor.Icons.Material.Filled.Verified,
BadgeIcon = GetSecurityBadgeIcon(requiresAudit: false, hasAudit, hasHashMismatch: false, isBlocked: false, canOverride: false),
Headline = TB("This assistant is currently unlocked."),
Description = string.Format(TB("The stored audit matches the current plugin code and meets your required minimum level '{0}'."), auditSettings.MinimumLevel.GetName()),
Description = string.Format(TB("The stored audit matches the current plugin code and meets your required minimum level '{0}'."), auditSettings.MinimumLevel.Name),
StatusColor = GetAvailabilityColor(requiresAudit: false, hasAudit, hasHashMismatch: false, isBlocked: false, canOverride: false),
StatusIcon = GetAvailabilityIcon(requiresAudit: false, hasAudit, hasHashMismatch: false, isBlocked: false, canOverride: false),
ActionLabel = TB("Open Security Check"),
@@ -306,6 +306,6 @@ public static class ConfigurationSnippetImport
return TB("The token or password of the data source cannot be decrypted on this computer. Such data sources can only be imported where the encryption secret of your organization is configured.");
}
return string.Format(TB("The pasted configuration is not a valid configuration of the type '{0}'."), type.GetName());
return string.Format(TB("The pasted configuration is not a valid configuration of the type '{0}'."), type.Name);
}
}
@@ -51,8 +51,8 @@ public sealed class ConfigurationSnippetParser
var section = parser.ReadBracketedString();
if (section != expectedSection)
throw new FormatException(PluginConfigurationObjectDescriptors.TryGet(section, out var otherDescriptor)
? string.Format(TB("The pasted configuration describes the type '{0}', but only the type '{1}' can be imported here."), otherDescriptor.Type.GetName(), type.GetName())
: string.Format(TB("The pasted configuration does not describe the type '{0}', which can be imported here."), type.GetName()));
? string.Format(TB("The pasted configuration describes the type '{0}', but only the type '{1}' can be imported here."), otherDescriptor.Type.Name, type.Name)
: string.Format(TB("The pasted configuration does not describe the type '{0}', which can be imported here."), type.Name));
parser.Expect('[');
parser.Expect('#');
@@ -2,7 +2,7 @@ namespace AIStudio.Tools.PluginSystem;
public readonly record struct InternalPluginData(PluginType Type, Guid Id, string ShortName)
{
public string ResourcePath => $"{this.Type.GetDirectory()}/{this.ShortName.ToLowerInvariant()}-{this.Id}";
public string ResourcePath => $"{this.Type.Directory}/{this.ShortName.ToLowerInvariant()}-{this.Id}";
public string ResourceName => $"{this.ShortName.ToLowerInvariant()}-{this.Id}";
}
@@ -6,7 +6,7 @@ public static class PluginCategoryExtensions
extension(PluginCategory type)
{
public string GetName() => type switch
public string Name => type switch
{
PluginCategory.NONE => TB("None"),
PluginCategory.CORE => TB("AI Studio Core"),
@@ -489,7 +489,7 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
var resultFileFormatIsValid = ManagedConfiguration.TryProcessConfiguration(x => x.BatchProcessing, x => x.ResultFileFormat, this.Id, settingsTable, dryRun, validator: DataBatchProcessing.IsValidResultFileFormat);
if (!resultFileFormatIsValid && settingsTable.TryGetValue("DataBatchProcessing.ResultFileFormat", out _))
LOG.LogWarning("The Batch Processing result file format configured by plugin {ConfigPluginId} must be one of {ResultFileFormats}.", this.Id, string.Join(", ", FileExportFormatExtensions.ANSWER_FORMATS));
LOG.LogWarning("The Batch Processing result file format configured by plugin {ConfigPluginId} must be one of {ResultFileFormats}.", this.Id, string.Join(", ", FileExportFormat.AnswerFormats));
ManagedConfiguration.TryProcessConfiguration(x => x.BatchProcessing, x => x.CsvFileName, this.Id, settingsTable, dryRun);
ManagedConfiguration.TryProcessConfiguration(x => x.BatchProcessing, x => x.ResultColumnHeader, this.Id, settingsTable, dryRun);
@@ -58,13 +58,13 @@ public sealed record PluginConfigurationObject
private static string DescribeEndpoint(IConfigurationObject configObject) => configObject switch
{
Settings.Provider { IsSelfHosted: true } provider => provider.Hostname,
Settings.Provider provider => Provider.LLMProvidersExtensions.ToName(provider.UsedLLMProvider),
Settings.Provider provider => Provider.LLMProvidersExtensions.ToName(provider.UsedLLMProvider, translate: true),
EmbeddingProvider { IsSelfHosted: true } embeddingProvider => embeddingProvider.Hostname,
EmbeddingProvider embeddingProvider => Provider.LLMProvidersExtensions.ToName(embeddingProvider.UsedLLMProvider),
EmbeddingProvider embeddingProvider => Provider.LLMProvidersExtensions.ToName(embeddingProvider.UsedLLMProvider, translate: true),
TranscriptionProvider { IsSelfHosted: true } transcriptionProvider => transcriptionProvider.Hostname,
TranscriptionProvider transcriptionProvider => Provider.LLMProvidersExtensions.ToName(transcriptionProvider.UsedLLMProvider),
TranscriptionProvider transcriptionProvider => Provider.LLMProvidersExtensions.ToName(transcriptionProvider.UsedLLMProvider, translate: true),
DataSourceERI_V1 dataSource => dataSource.Hostname,
@@ -9,7 +9,7 @@ public static class PluginConfigurationObjectTypeExtensions
/// <summary>
/// The name of a type of configuration object, as users read it, e.g., in a message.
/// </summary>
public string GetName() => type switch
public string Name => type switch
{
PluginConfigurationObjectType.LLM_PROVIDER => TB("LLM Provider"),
PluginConfigurationObjectType.EMBEDDING_PROVIDER => TB("Embedding Provider"),
@@ -87,7 +87,7 @@ public static partial class PluginFactory
{
await using var inputStream = resourceFilePath.CreateReadStream();
var pluginTypeBasePath = Path.Join(INTERNAL_PLUGINS_ROOT, metaData.Type.GetDirectory());
var pluginTypeBasePath = Path.Join(INTERNAL_PLUGINS_ROOT, metaData.Type.Directory);
if (!Directory.Exists(INTERNAL_PLUGINS_ROOT))
Directory.CreateDirectory(INTERNAL_PLUGINS_ROOT);
@@ -6,7 +6,7 @@ public static class PluginTargetGroupExtensions
extension(PluginTargetGroup group)
{
public string Name() => group switch
public string Name => group switch
{
PluginTargetGroup.NONE => TB("No target group"),
@@ -6,7 +6,7 @@ public static class PluginTypeExtensions
extension(PluginType type)
{
public string GetName() => type switch
public string Name => type switch
{
PluginType.LANGUAGE => TB("Language plugin"),
PluginType.ASSISTANT => TB("Assistant plugin"),
@@ -17,7 +17,7 @@ public static class PluginTypeExtensions
_ => TB("Unknown plugin type"),
};
public string GetDirectory() => type switch
public string Directory => type switch
{
PluginType.LANGUAGE => "languages",
PluginType.ASSISTANT => "assistants",