diff --git a/docs/AspDotNetCore.md b/docs/AspDotNetCore.md index a3afdad70..ee694b1e0 100644 --- a/docs/AspDotNetCore.md +++ b/docs/AspDotNetCore.md @@ -94,7 +94,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF ```html ``` -Note: `` has many options like `max-traces`, `position`, etc. [You can find them in code here](https://github.com/MiniProfiler/dotnet/blob/master/src/MiniProfiler.AspNetCore.Mvc/MiniProfilerScriptTagHelper.cs). +Note: `` has many options like `max-traces`, `position`, `color-scheme`, `nonce`, etc. [You can find them in code here](https://github.com/MiniProfiler/dotnet/blob/master/src/MiniProfiler.AspNetCore.Mvc/MiniProfilerScriptTagHelper.cs). Note #2: The above tag helper registration may go away in future versions of ASP.NET Core, they're working on smoother alternatives here. diff --git a/docs/Releases.md b/docs/Releases.md index 74f926e2c..099d5fc11 100644 --- a/docs/Releases.md +++ b/docs/Releases.md @@ -5,6 +5,18 @@ layout: "default" ### Release Notes This page tracks major changes included in any update starting with version 4.0.0.3 +#### Version 4.2.0 (In preview) +- Added `"; + Assert.Equal(expected, result); + } + + [Fact] + public void OptionsSet() + { + var profiler = GetBasicProfiler(); + var renderOptions = new RenderOptions() + { + ColorScheme = ColorScheme.Auto, + MaxTracesToShow = 12, + Nonce = "myNonce", + PopupToggleKeyboardShortcut = "Alt+Q", + Position = RenderPosition.Right, + ShowControls = true, + ShowTimeWithChildren = true, + ShowTrivial = true, + StartHidden = true, + TrivialDurationThresholdMilliseconds = 23 + }; + var result = Render.Includes(profiler, "/", true, renderOptions, new List() { profiler.Id }); + Output.WriteLine("Result: " + result); + + Assert.NotNull(result); + Assert.Contains("id=\"mini-profiler\"", result); + + var expected = $@""; + Assert.Equal(expected, result); + } + + [Theory] + [InlineData(null, @"data-scheme=""Light""")] + [InlineData(ColorScheme.Auto, @"data-scheme=""Auto""")] + [InlineData(ColorScheme.Dark, @"data-scheme=""Dark""")] + [InlineData(ColorScheme.Light, @"data-scheme=""Light""")] + public void ColorSchemes(ColorScheme? scheme, string expected) + { + var profiler = GetBasicProfiler(); + var renderOptions = new RenderOptions() { ColorScheme = scheme }; + + var result = Render.Includes(profiler, " / ", true, renderOptions); + Output.WriteLine("Result: " + result); + + Assert.NotNull(result); + Assert.Contains(expected, result); + } + + [Theory] + [InlineData(null, @"data-position=""Left""")] + [InlineData(RenderPosition.BottomLeft, @"data-position=""BottomLeft""")] + [InlineData(RenderPosition.BottomRight, @"data-position=""BottomRight""")] + [InlineData(RenderPosition.Left, @"data-position=""Left""")] + [InlineData(RenderPosition.Right, @"data-position=""Right""")] + public void Positions(RenderPosition? position, string expected) + { + var profiler = GetBasicProfiler(); + var renderOptions = new RenderOptions() { Position = position }; + + var result = Render.Includes(profiler, " / ", true, renderOptions); + Output.WriteLine("Result: " + result); + + Assert.NotNull(result); + Assert.Contains(expected, result); + } + + [Fact] + public void Nonce() + { + var profiler = GetBasicProfiler(); + var renderOptions = new RenderOptions(); + + // Default + var result = Render.Includes(profiler, "/", true, renderOptions); + Output.WriteLine("Result: " + result); + Assert.DoesNotContain("nonce", result); + + // With nonce + var nonce = Guid.NewGuid().ToString(); + renderOptions.Nonce = nonce; + result = Render.Includes(profiler, "/", true, renderOptions); + Assert.Contains($@"nonce=""{nonce}""", result); + } + + [Theory] + [InlineData("foo", @"nonce=""foo""")] + [InlineData("foo!@#$%", @"nonce=""foo!@#$%""")] + [InlineData("e31df82b-5102-4134-af97-f29bf724bedd", @"nonce=""e31df82b-5102-4134-af97-f29bf724bedd""")] + [InlineData("f\"oo", @"nonce=""f"oo""")] + [InlineData("󆲢L軾󯮃򮬛ŝ󅫤򄷌򆰃񟕺􆷀;鮡ƾ󤕵ԁf\'\"&23", @"nonce=""󆲢L軾󯮃򮬛ŝ󅫤򄷌򆰃񟕺􆷀;鮡ƾ󤕵ԁf'"&23""")] + public void NonceEncoding(string nonce, string expected) + { + var profiler = GetBasicProfiler(); + var renderOptions = new RenderOptions() { Nonce = nonce }; + + var result = Render.Includes(profiler, "/", true, renderOptions); + Assert.Contains(expected, result); + } + } +}