Documentation Index
Fetch the complete documentation index at: https://mintlify.com/DevToys-app/DevToys/llms.txt
Use this file to discover all available pages before exploring further.
IResourceAssemblyIdentifier acts as the entry-point through which DevToys locates the string resources (.resx / ResourceManager) and custom fonts bundled inside your extension assembly. Every extension assembly must export exactly one implementation. The [Name] you give it is the string you reference in the ResourceManagerAssemblyIdentifier property of every [ToolDisplayInformation] attribute in that assembly — forming the link between your tool metadata and its localized strings.
Namespace: DevToys.Api
Interface Declaration
public interface IResourceAssemblyIdentifier
{
ValueTask<FontDefinition[]> GetFontDefinitionsAsync();
}
Members
GetFontDefinitionsAsync()
ValueTask<FontDefinition[]>
Returns an array of FontDefinition objects, each describing a custom font bundled as an embedded resource in your assembly. Return an empty array if you rely only on built-in fonts (e.g., FluentSystemIcons).The font name you supply in FontDefinition.FontFamily is the value you use in the IconFontName property of [ToolDisplayInformation], so they must match exactly.
FontDefinition
FontDefinition pairs a font family name with a readable Stream pointing at the embedded font file. It implements IDisposable — DevToys disposes each instance after loading the font.
public sealed class FontDefinition : IDisposable
{
public FontDefinition(string fontFamily, Stream fontReader);
public string FontFamily { get; } // Name used in IconFontName attributes
public Stream FontReader { get; } // Readable stream of the TTF/OTF file
public void Dispose(); // Disposes FontReader
}
Only TTF and OTF font formats are supported. WOFF and WOFF2 are not supported at this time. Embed your font file as an assembly resource and open it with Assembly.GetManifestResourceStream.
Minimum Implementation (No Custom Fonts)
Most extensions that use a built-in icon font (such as FluentSystemIcons) do not need to provide custom fonts. Return an empty array:
[Export(typeof(MyResourceAssemblyIdentifier))]
[Name(nameof(MyResourceAssemblyIdentifier))]
internal sealed class MyResourceAssemblyIdentifier : IResourceAssemblyIdentifier
{
public ValueTask<FontDefinition[]> GetFontDefinitionsAsync()
{
return ValueTask.FromResult(Array.Empty<FontDefinition>());
}
}
The [Name] value on your IResourceAssemblyIdentifier export must exactly match the string you pass to ResourceManagerAssemblyIdentifier inside every [ToolDisplayInformation] in that assembly. A mismatch causes DevToys to fail to resolve the tool’s localized strings and icon.
Implementation With a Custom Font
If your tool uses a custom icon glyph font or a specialized display font, embed the .ttf or .otf file in your project and stream it at runtime:
[Export(typeof(MyResourceAssemblyIdentifier))]
[Name(nameof(MyResourceAssemblyIdentifier))]
internal sealed class MyResourceAssemblyIdentifier : IResourceAssemblyIdentifier
{
public ValueTask<FontDefinition[]> GetFontDefinitionsAsync()
{
var assembly = Assembly.GetExecutingAssembly();
// The resource name mirrors your project's default namespace + folder + filename.
Stream? fontStream = assembly.GetManifestResourceStream(
"MyProject.Assets.Fonts.MyCustomIcons.ttf");
if (fontStream is null)
{
return ValueTask.FromResult(Array.Empty<FontDefinition>());
}
var fontDefinition = new FontDefinition(
fontFamily: "MyCustomIcons", // Must match IconFontName in [ToolDisplayInformation]
fontReader: fontStream);
return ValueTask.FromResult(new[] { fontDefinition });
}
}
Then reference the font name in your tool attribute:
[ToolDisplayInformation(
IconFontName = "MyCustomIcons", // matches FontDefinition.FontFamily above
IconGlyph = '\uE001',
ResourceManagerAssemblyIdentifier = nameof(MyResourceAssemblyIdentifier),
ResourceManagerBaseName = "MyProject.Strings",
ShortDisplayTitleResourceName = nameof(MyProject.Strings.ShortDisplayTitle))]
The diagram below shows how the three values must align:
[Name(nameof(MyResourceAssemblyIdentifier))] ← on IResourceAssemblyIdentifier
↕ must match
ResourceManagerAssemblyIdentifier = nameof(MyResourceAssemblyIdentifier) ← in [ToolDisplayInformation]
↕ resolves
ResourceManagerBaseName = "MyProject.Strings" ← fully-qualified resource base name
IMefProvider
IMefProvider is a companion interface that can be imported into any MEF component to dynamically resolve exports at runtime — useful when you cannot take a direct [Import] at construction time.
public interface IMefProvider
{
// Resolves a single exported implementation of TExport.
TExport Import<TExport>();
// Resolves all exported implementations of TExport with their metadata.
IEnumerable<Lazy<TExport, TMetadataView>> ImportMany<TExport, TMetadataView>();
// Satisfies [Import] / [ImportMany] fields on an existing object instance.
void SatisfyImports(object @object);
}
Inject it the same way as any other DevToys service:
[Import]
private IMefProvider _mefProvider = null!;
// Later, at runtime:
ISettingsProvider settings = _mefProvider.Import<ISettingsProvider>();
Use SatisfyImports(this) in the constructor of a class that was created with new (i.e., outside of MEF) but still needs its [Import] fields populated by the container.
See Also