public static string GetProviderNamespace()

in src/TemplateRefGenerator/Utils/Utils.cs [13:42]


    public static string GetProviderNamespace(string resourceType)
        => resourceType.Split('/', 2)[0];

    public static string GetUnqualifiedType(string resourceType)
        => resourceType.Split('/', 2)[1];

    public static string? TryReadManifestFile(params string[] pathComponents)
        => typeof(Utils).Assembly.GetManifestResourceStream(GetManifestFilePath(pathComponents)) is Stream stream
            ? new StreamReader(stream).ReadToEnd()
            : null;

    public static string ReadManifestFile(params string[] pathComponents)
        => TryReadManifestFile(pathComponents) ?? throw new InvalidOperationException($"File {GetManifestFilePath(pathComponents)} does not exist");

    public static string GetManifestFilePath(string[] pathComponents)
        => string.Join('/', pathComponents);

    public static T DeserializeJsonFile<T>(string filePath, string contents)
    {
        var options = new JsonSerializerOptions
        {
            Converters = 
            {
                new JsonStringEnumConverter(JsonNamingPolicy.CamelCase)
            }
        };

        return JsonSerializer.Deserialize<T>(contents, options) ??
            throw new InvalidOperationException($"Failed to deserialize file {filePath}");
    }