Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Feb 18, 2024
1 parent 797362f commit 2a4b91a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
15 changes: 15 additions & 0 deletions api_list.include.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,18 @@
* `Boolean TryFormat(Span<Char>, Int32&, ReadOnlySpan<Char>, IFormatProvider)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.uint64.tryformat)


### Static helpers

#### EnumPolyfill

* `String[] GetNames<TEnum>()` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.enum.getnames)
* `TEnum[] GetValues<TEnum>()` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.enum.getvalues)


#### RegexPolyfill

* `Boolean IsMatch(String, RegularExpressions.RegexOptions, TimeSpan)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.regularexpressions.regex.ismatch#system-text-regularexpressions-regex-ismatch(system-readonlyspan((system-char))-system-string-system-text-regularexpressions-regexoptions-system-timespan))
* `Boolean IsMatch(String, RegularExpressions.RegexOptions)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.regularexpressions.regex.ismatch#system-text-regularexpressions-regex-ismatch(system-readonlyspan((system-char))-system-string-system-text-regularexpressions-regexoptions))
* `Boolean IsMatch(String)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.regularexpressions.regex.ismatch#system-text-regularexpressions-regex-ismatch(system-readonlyspan((system-char))-system-string))


15 changes: 15 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,21 @@ The class `Polyfill` includes the following extension methods:

* `Boolean TryFormat(Span<Char>, Int32&, ReadOnlySpan<Char>, IFormatProvider)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.uint64.tryformat)


### Static helpers

#### EnumPolyfill

* `String[] GetNames<TEnum>()` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.enum.getnames)
* `TEnum[] GetValues<TEnum>()` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.enum.getvalues)


#### RegexPolyfill

* `Boolean IsMatch(String, RegularExpressions.RegexOptions, TimeSpan)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.regularexpressions.regex.ismatch#system-text-regularexpressions-regex-ismatch(system-readonlyspan((system-char))-system-string-system-text-regularexpressions-regexoptions-system-timespan))
* `Boolean IsMatch(String, RegularExpressions.RegexOptions)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.regularexpressions.regex.ismatch#system-text-regularexpressions-regex-ismatch(system-readonlyspan((system-char))-system-string-system-text-regularexpressions-regexoptions))
* `Boolean IsMatch(String)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.regularexpressions.regex.ismatch#system-text-regularexpressions-regex-ismatch(system-readonlyspan((system-char))-system-string))

<!-- endInclude -->


Expand Down
22 changes: 21 additions & 1 deletion src/Tests/BuildApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public void Run()
var md = Path.Combine(solutionDirectory, "..", "api_list.include.md");
File.Delete(md);
using var module = ModuleDefinition.ReadModule(path);
var extensions = module.GetTypes().Single(_ => _.Name == nameof(Polyfill));
var types = module.GetTypes().ToList();
var extensions = types.Single(_ => _.Name == nameof(Polyfill));
using var writer = File.CreateText(md);

writer.WriteLine($"### Extension methods");
Expand All @@ -44,6 +45,25 @@ public void Run()
writer.WriteLine();
writer.WriteLine();
}
writer.WriteLine($"### Static helpers");
writer.WriteLine();

WriteHelper(types, nameof(EnumPolyfill), writer);
WriteHelper(types, "RegexPolyfill", writer);
}

static void WriteHelper(List<TypeDefinition> types, string name, StreamWriter writer)
{
var helper = types.Single(_ => _.Name == name);

writer.WriteLine($"#### {helper.Name}");
writer.WriteLine();
foreach (var method in PublicMethods(helper.Methods))
{
WriteSignature(method, writer);
}
writer.WriteLine();
writer.WriteLine();
}

static string GetTypeName(string targetType)
Expand Down

0 comments on commit 2a4b91a

Please sign in to comment.