Skip to content

Commit

Permalink
Merge branch 'dev' into feature/datagrid-selectallcheckboxes-indeterm…
Browse files Browse the repository at this point in the history
…inatestate
  • Loading branch information
ScarletKuro authored Apr 3, 2024
2 parents 03cfaaa + 0dcc84c commit 6a3060e
Show file tree
Hide file tree
Showing 549 changed files with 5,686 additions and 16,205 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ Please make sure that you follow our [code of conduct](/CODE_OF_CONDUCT.md)
- If there are new changes in the main repo, you should either merge the main repo's (upstream) dev or rebase your branch onto it.
- Before working on a large change, it is recommended to first open an issue to discuss it with others
- If your Pull Request is still in progress, convert it to a draft Pull Request
- Your commit messages should follow the following format:
- The PR Title should follow the following format:
```
<component name>: <short description of changes in imperative> (<linked issue>)
```
For example:
```
DateRangePicker: Fix initializing DateRange with null values (#1997)
```

- To keep your branch up to date with the `dev` branch simply merge `dev`. **Don't rebase** because if you rebase the wrong direction your PR will include tons of unrelated commits from dev.
- Your Pull Request should not include any unnecessary refactoring
- If there are visual changes, you should include a screenshot, gif or video
- If there are any coresponding issues, link them to the Pull Request. Include `Fixes #<issue nr>` for bug fixes and `Closes #<issue nr>` for other issues in the description ([Link issues guide](https://docs.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword))
Expand Down
7 changes: 5 additions & 2 deletions src/MudBlazor.Docs.Compiler/CodeSnippets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace MudBlazor.Docs.Compiler
{
public class CodeSnippets
public partial class CodeSnippets
{
public bool Execute()
{
Expand Down Expand Up @@ -61,8 +61,11 @@ public bool Execute()
private static string EscapeComponentSource(string path)
{
var source = File.ReadAllText(path, Encoding.UTF8);
source = Regex.Replace(source, "@(namespace|layout|page) .+?\n", string.Empty);
source = NamespaceLayoutOrPageRegularExpression().Replace(source, string.Empty);
return source.Replace("\"", "\"\"").Trim();
}

[GeneratedRegex("@(namespace|layout|page) .+?\n")]
private static partial Regex NamespaceLayoutOrPageRegularExpression();
}
}
29 changes: 22 additions & 7 deletions src/MudBlazor.Docs.Compiler/DocStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Microsoft.AspNetCore.Components;
namespace MudBlazor.Docs.Compiler
{
public class DocStrings
public partial class DocStrings
{
private static string[] hiddenMethods = { "ToString", "GetType", "GetHashCode", "Equals", "SetParametersAsync", "ReferenceEquals" };

Expand Down Expand Up @@ -38,7 +38,7 @@ public bool Execute()
{
var doc = property.GetDocumentation() ?? "";
doc = convertSeeTags(doc);
doc = Regex.Replace(doc, @"</?.+?>", ""); // remove all other XML tags
doc = XmlTagRegularExpression().Replace(doc, ""); // remove all other XML tags
cb.AddLine($"public const string {GetSaveTypename(type)}_{property.Name} = @\"{EscapeDescription(doc).Trim()}\";\n");
}

Expand Down Expand Up @@ -83,15 +83,15 @@ public bool Execute()
return success;
}

private static string GetSaveTypename(Type t) => Regex.Replace(t.ConvertToCSharpSource(), @"[\.,<>]", "_").TrimEnd('_');
private static string GetSaveTypename(Type t) => SaveTypenameRegularExpression().Replace(t.ConvertToCSharpSource(), "_").TrimEnd('_');

/* Methods can be overloaded so the method name doesn't identify it uniquely. Instead of method name we need the method signature.
* Currently the return type of a method is also used, but probably it can be removed.
*
* Alternatively we could use the format similar to this used in XML documentation - it will be even better because I think it is
* less likely to be changed in the future. See XmlDocumentation.cs for a method computing identifiers.
*/
private static string GetSaveMethodIdentifier(MethodInfo method) => Regex.Replace(method.ToString(), "[^A-Za-z0-9_]", "_");
private static string GetSaveMethodIdentifier(MethodInfo method) => AlphanumericUnderscoreRegularExpression().Replace(method.ToString(), "_");

private static Type GetBaseDefinitionClass(MethodInfo m) => m.GetBaseDefinition().DeclaringType;

Expand All @@ -100,10 +100,10 @@ public bool Execute()
*/
private static string convertSeeTags(string doc)
{
return Regex.Replace(doc, "<see cref=\"[TFPME]:(MudBlazor\\.)?([^>]+)\" */>", match =>
return SeeCrefRegularExpression().Replace(doc, match =>
{
string result = match.Groups[2].Value; // get the name of Type or type member (Field, Property, Method, or Event)
result = Regex.Replace(result, "`1", ""); // remove `1 from generic type name
var result = match.Groups[2].Value; // get the name of Type or type member (Field, Property, Method, or Event)
result = BacktickRegularExpression().Replace(result, ""); // remove `1 from generic type name
return result;
});
}
Expand All @@ -112,5 +112,20 @@ private static string EscapeDescription(string doc)
{
return doc.Replace("\"", "\"\"");
}

[GeneratedRegex(@"</?.+?>")]
private static partial Regex XmlTagRegularExpression();

[GeneratedRegex(@"[\.,<>]")]
private static partial Regex SaveTypenameRegularExpression();

[GeneratedRegex("[^A-Za-z0-9_]")]
private static partial Regex AlphanumericUnderscoreRegularExpression();

[GeneratedRegex("<see cref=\"[TFPME]:(MudBlazor\\.)?([^>]+)\" */>")]
private static partial Regex SeeCrefRegularExpression();

[GeneratedRegex("`1")]
private static partial Regex BacktickRegularExpression();
}
}
30 changes: 21 additions & 9 deletions src/MudBlazor.Docs.Compiler/ExamplesMarkup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace MudBlazor.Docs.Compiler
{
public class ExamplesMarkup
public partial class ExamplesMarkup
{
public bool Execute()
{
Expand Down Expand Up @@ -50,7 +50,7 @@ public bool Execute()

var src = StripComponentSource(entry.FullName);
var blocks = src.Split("@code");
var blocks0 = Regex.Replace(blocks[0], @"</?DocsFrame>", string.Empty)
var blocks0 = DocsFrameEndTagRegularExpression().Replace(blocks[0], string.Empty)
.Replace("@", "PlaceholdeR")
.Trim();

Expand Down Expand Up @@ -110,16 +110,13 @@ public bool Execute()
private static string StripComponentSource(string path)
{
var source = File.ReadAllText(path, Encoding.UTF8);
source = Regex.Replace(source, "@(namespace|layout|page) .+?\n", string.Empty);
source = NamespaceLayoutOrPageRegularExpression().Replace(source, string.Empty);
return source.Trim();
}

public static string AttributePostprocessing(string html)
{
return Regex.Replace(
html,
@"<span class=""htmlAttributeValue"">&quot;(?'value'.*?)&quot;</span>",
new MatchEvaluator(m =>
return HtmlAttributeValueSpanRegularExpression().Replace(html, new MatchEvaluator(m =>
{
var value = m.Groups["value"].Value;
return
Expand All @@ -133,18 +130,33 @@ private static string AttributeValuePostprocessing(string value)
return value;
if (value is "true" or "false")
return $"<span class=\"keyword\">{value}</span>";
if (Regex.IsMatch(value, "^[A-Z][A-Za-z0-9]+[.][A-Za-z][A-Za-z0-9]+$"))
if (AlphanumericDotAlphanumericRegularExpression().IsMatch(value))
{
var tokens = value.Split('.');
return $"<span class=\"enum\">{tokens[0]}</span><span class=\"enumValue\">.{tokens[1]}</span>";
}

if (Regex.IsMatch(value, "^@[A-Za-z0-9]+$"))
if (AlphanumericRegularExpression().IsMatch(value))
{
return $"<span class=\"sharpVariable\">{value}</span>";
}

return $"<span class=\"htmlAttributeValue\">{value}</span>";
}

[GeneratedRegex(@"</?DocsFrame>")]
private static partial Regex DocsFrameEndTagRegularExpression();

[GeneratedRegex("@(namespace|layout|page) .+?\n")]
private static partial Regex NamespaceLayoutOrPageRegularExpression();

[GeneratedRegex(@"<span class=""htmlAttributeValue"">&quot;(?'value'.*?)&quot;</span>")]
private static partial Regex HtmlAttributeValueSpanRegularExpression();

[GeneratedRegex("^[A-Z][A-Za-z0-9]+[.][A-Za-z][A-Za-z0-9]+$")]
private static partial Regex AlphanumericDotAlphanumericRegularExpression();

[GeneratedRegex("^@[A-Za-z0-9]+$")]
private static partial Regex AlphanumericRegularExpression();
}
}
7 changes: 5 additions & 2 deletions src/MudBlazor.Docs.Compiler/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

namespace MudBlazor.Docs.Compiler
{
public static class StringExtensions
public static partial class StringExtensions
{

public static string ToLfLineEndings(this string self)
{
if (self == null)
return null;
return Regex.Replace(self, @"\r?\n", "\n");
return NewLineRegularExpression().Replace(self, "\n");
}

[GeneratedRegex(@"\r?\n")]
private static partial Regex NewLineRegularExpression();
}
}
2 changes: 1 addition & 1 deletion src/MudBlazor.Docs.Compiler/TestsForApiPages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static bool IsObsolete(Type type)
{
var attributes = (ObsoleteAttribute[])
type.GetCustomAttributes(typeof(ObsoleteAttribute), false);
return (attributes != null && attributes.Length > 0);
return attributes != null && attributes.Length > 0;
}

private static string SafeTypeName(Type type, bool removeT = false)
Expand Down
21 changes: 15 additions & 6 deletions src/MudBlazor.Docs.Compiler/XmlDocumentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace MudBlazor.Docs.Compiler
{
public static class XmlDocumentation
public static partial class XmlDocumentation
{

#region System.Reflection.Assembly
Expand Down Expand Up @@ -208,7 +208,7 @@ string ConvertToCsharpSource(Type type)
var result = type.IsNested
? ConvertToCsharpSource(type.DeclaringType) + "."
: ""; //: type.Namespace + ".";
result += Regex.Replace(type.Name, "`.*", string.Empty);
result += BacktickRegularExpression().Replace(type.Name, string.Empty);
if (type.IsGenericType)
{
result += "<";
Expand Down Expand Up @@ -440,7 +440,7 @@ public static string GetXmlDocumentationFormattedString(
: type.Namespace + ".";

string typeNameString = isMethodParameter
? typeNameString = Regex.Replace(type.Name, @"`\d+", string.Empty)
? typeNameString = TypeNameRegularExpression().Replace(type.Name, string.Empty)
: typeNameString = type.Name;

var genericArgumentsString = type.IsGenericType && isMethodParameter
Expand Down Expand Up @@ -498,8 +498,8 @@ public static string GetDocumentation(this EventInfo eventInfo)

public static string XmlDocumentationKeyHelper(string typeFullNameString, string memberNameString)
{
var key = Regex.Replace(typeFullNameString, @"\[.*\]", string.Empty).Replace('+', '.');
if (!(memberNameString is null))
var key = DocumentationKeyRegularExpression().Replace(typeFullNameString, string.Empty).Replace('+', '.');
if (memberNameString is not null)
{
key += "." + memberNameString;
}
Expand Down Expand Up @@ -562,7 +562,7 @@ public static string GetDocumentation(this MemberInfo memberInfo)
public static string GetDocumentation(this ParameterInfo parameterInfo)
{
var memberDocumentation = parameterInfo.Member.GetDocumentation();
if (!(memberDocumentation is null))
if (memberDocumentation is not null)
{
var regexPattern =
Regex.Escape(@"<param name=" + "\"" + parameterInfo.Name + "\"" + @">") +
Expand All @@ -578,6 +578,15 @@ public static string GetDocumentation(this ParameterInfo parameterInfo)
return null;
}

[GeneratedRegex("`.*")]
private static partial Regex BacktickRegularExpression();

[GeneratedRegex(@"`\d+")]
private static partial Regex TypeNameRegularExpression();

[GeneratedRegex(@"\[.*\]")]
private static partial Regex DocumentationKeyRegularExpression();

#endregion

}
Expand Down
9 changes: 4 additions & 5 deletions src/MudBlazor.Docs.Wasm/Program.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using Microsoft.AspNetCore.Components.Web;
using System;
using System.Net.Http;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.JSInterop;

using System;
using System.Net.Http;
using MudBlazor.Docs.Wasm;
using MudBlazor.Docs.Extensions;
using MudBlazor.Docs.Services.Notifications;
using MudBlazor.Docs.Wasm;

var builder = WebAssemblyHostBuilder.CreateDefault(args);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task<IActionResult> SearchWithDelay(CancellationToken cancellationT
List<string> result = new();
foreach (var item in states)
{
if (string.IsNullOrEmpty(input) == true || item.Contains(input, StringComparison.InvariantCultureIgnoreCase))
if (string.IsNullOrEmpty(input) || item.Contains(input, StringComparison.InvariantCultureIgnoreCase))
{
result.Add(item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// MudBlazor licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc;
using System;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;

namespace MudBlazor.Docs.WasmHost.Controllers
{
Expand Down
6 changes: 3 additions & 3 deletions src/MudBlazor.Docs.WasmHost/Prerender/ICrawlerIdentifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public interface ICrawlerIdentifier

public class FileBasedCrawlerIdentifier : ICrawlerIdentifier
{
private record CrawlerEntry(string Pattern, string Url, IEnumerable<String> Instances);
private record CrawlerEntry(string Pattern, string Url, IEnumerable<string> Instances);

private readonly string _filename;
private LimitedConcurrentDictionary<string, bool> _cache = new(1_000);
Expand All @@ -49,11 +49,11 @@ public Task<bool> IsRequestByCrawler(HttpContext context)
if (userAgentHeader.Any() == false) { return Task.FromResult(false); }

var value = userAgentHeader.First();
if (_cache.ContainsKey(value) == true) { return Task.FromResult(_cache[value]); }
if (_cache.ContainsKey(value)) { return Task.FromResult(_cache[value]); }

foreach (var item in _patterns)
{
if (item.IsMatch(value) == true)
if (item.IsMatch(value))
{
_cache.TryAdd(value, true);
return Task.FromResult(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ namespace MudBlazor.Docs.WasmHost.Prerender
public class LimitedConcurrentDictionary<TKey, TValue>
{
private ConcurrentDictionary<TKey, TValue> _dict = new();
private Int32 MaxCapacity { get; init; }
private int MaxCapacity { get; init; }

public LimitedConcurrentDictionary(Int32 maxCapacity)
public LimitedConcurrentDictionary(int maxCapacity)
{
MaxCapacity = maxCapacity;
}
Expand Down
4 changes: 2 additions & 2 deletions src/MudBlazor.Docs.WasmHost/Prerender/PrerenderMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public PrerenderMiddleware(RequestDelegate next, ICrawlerIdentifier crawlerIdent
public async Task Invoke(HttpContext context)
{
var path = context.Request.Path.ToString().ToLower();
if (path.Contains("webapi") == true)
if (path.Contains("webapi"))
{
await _next(context);
return;
Expand All @@ -38,7 +38,7 @@ public async Task Invoke(HttpContext context)
}
else
{
if (_responseCache.ContainsKey(path) == true)
if (_responseCache.ContainsKey(path))
{
context.Response.StatusCode = 200;
context.Response.ContentType = "text/html; charset=utf-8";
Expand Down
2 changes: 1 addition & 1 deletion src/MudBlazor.Docs.WasmHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using MudBlazor.Docs.Extensions;
using MudBlazor.Docs.WasmHost.Prerender;
using MudBlazor.Docs.Services;
using MudBlazor.Docs.Services.Notifications;
using MudBlazor.Docs.WasmHost.Prerender;
using MudBlazor.Examples.Data;

var builder = WebApplication.CreateBuilder(args);
Expand Down
2 changes: 1 addition & 1 deletion src/MudBlazor.Docs/Components/DocsApi.razor
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<CodeInline>@context.Name</CodeInline>
@if (_propertiesGrouping == Grouping.Inheritance && IsOverridden(context.PropertyInfo))
{
<MudChip Variant="Variant.Outlined" Color="Color.Secondary" Size="Size.Small">overridden</MudChip>
<MudChip T="string" Variant="Variant.Outlined" Color="Color.Secondary" Size="Size.Small">overridden</MudChip>
}
</MudTd>
<MudTd Class="docs-content-api-cell" DataLabel="Type">
Expand Down
2 changes: 1 addition & 1 deletion src/MudBlazor.Docs/Components/DocsPage.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using MudBlazor.Docs.Models;
Expand Down
Loading

0 comments on commit 6a3060e

Please sign in to comment.