Skip to content

Commit 3b1c46a

Browse files
committed
Code Cleanup - Minor code cleanup
- Add Microsoft.CodeAnalysis.NetAnalyzers package - Make some classes sealed - Fix/Add xml doc
1 parent 12d28b6 commit 3b1c46a

24 files changed

+129
-23
lines changed

CefSharp.WinForms/Experimental/ChromiumRenderWidgetHandleFinder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static bool TryFindHandle(IBrowser browser, out IntPtr chromerRenderWidge
7878
/// Helper function used to find the child HWND with the ClassName matching <paramref name="chromeRenderWidgetHostClassName"/>
7979
/// Chromium's message-loop Window isn't created synchronously, so this may not find it.
8080
/// If so, you need to wait and try again later.
81-
/// In most cases you should use the <see cref="TryFindHandle(ChromiumWebBrowser, out IntPtr)"/> overload.
81+
/// In most cases you should use the <see cref="TryFindHandle(IWebBrowser, out IntPtr)"/> overload.
8282
/// </summary>
8383
/// <param name="chromiumWebBrowserHandle"><see cref="ChromiumWebBrowser"/> control Handle</param>
8484
/// <param name="chromeRenderWidgetHostClassName">class name used to match</param>

CefSharp.WinForms/Handler/LifeSpanHandlerBuilder.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ public class LifeSpanHandlerBuilder
1111
{
1212
private readonly LifeSpanHandler handler;
1313

14+
/// <summary>
15+
/// LifeSpanHandlerBuilder
16+
/// </summary>
17+
/// <param name="chromiumHostControlCreatedDelegate">
18+
/// When specified the delegate will be used to create the <see cref="Host.ChromiumHostControl"/>
19+
/// instance. Allowing users to create their own custom instance that extends <see cref="Host.ChromiumHostControl"/>
20+
/// </param>
1421
public LifeSpanHandlerBuilder(CreatePopupChromiumHostControl chromiumHostControlCreatedDelegate)
1522
{
1623
handler = new LifeSpanHandler(chromiumHostControlCreatedDelegate);
@@ -30,9 +37,9 @@ public LifeSpanHandlerBuilder OnBeforePopupCreated(OnBeforePopupCreatedDelegate
3037
}
3138

3239
/// <summary>
33-
/// The <see cref="OnPopupCreatedDelegate"/> will be called when the<see cref="ChromiumHostControl"/> has been
40+
/// The <see cref="OnPopupCreatedDelegate"/> will be called when the<see cref="Host.ChromiumHostControl"/> has been
3441
/// created. When the <see cref="OnPopupCreatedDelegate"/> is called you must add the control to it's intended parent
35-
/// so the <see cref="Control.ClientRectangle"/> can be calculated to set the initial
42+
/// so the <see cref="System.Windows.Forms.Control.ClientRectangle"/> can be calculated to set the initial
3643
/// size correctly.
3744
/// </summary>
3845
/// <param name="onPopupCreated">Action to be invoked when the Popup is to be destroyed.</param>
@@ -60,9 +67,9 @@ public LifeSpanHandlerBuilder OnPopupBrowserCreated(OnPopupBrowserCreatedDelegat
6067
}
6168

6269
/// <summary>
63-
/// The <see cref="OnPopupDestroyedDelegate"/> will be called when the <see cref="ChromiumHostControl"/> is to be
70+
/// The <see cref="OnPopupDestroyedDelegate"/> will be called when the <see cref="Host.ChromiumHostControl"/> is to be
6471
/// removed from it's parent.
65-
/// When the <see cref="OnPopupDestroyedDelegate"/> is called you must remove/dispose of the <see cref="ChromiumHostControl"/>.
72+
/// When the <see cref="OnPopupDestroyedDelegate"/> is called you must remove/dispose of the <see cref="Host.ChromiumHostControl"/>.
6673
/// </summary>
6774
/// <param name="onPopupDestroyed">Action to be invoked when the Popup is to be destroyed.</param>
6875
/// <returns><see cref="LifeSpanHandlerBuilder"/> instance allowing you to chain method calls together</returns>

CefSharp.WinForms/Host/ChromiumHostControl.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ public void LoadUrl(string url)
242242
}
243243
}
244244

245+
/// <inheritdoc/>
245246
public Task<LoadUrlAsyncResponse> LoadUrlAsync(string url)
246247
{
247248
//LoadUrlAsync is actually a static method so that CefSharp.Wpf.HwndHost can reuse the code
@@ -264,6 +265,7 @@ public IFrame GetMainFrame()
264265
return browser.MainFrame;
265266
}
266267

268+
/// <inheritdoc/>
267269
protected override void Dispose(bool disposing)
268270
{
269271
if (disposing)

CefSharp.WinForms/WebBrowserExtensions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public static bool DestroyWindow(this IChromiumWebBrowserBase chromiumWebBrowser
6868
/// </summary>
6969
/// <param name="chromiumWebBrowser"><see cref="ChromiumWebBrowser"/> instance</param>
7070
/// <param name="parentControl">Control used as the parent for DevTools (a custom control will be added to the <see cref="Control.Controls"/> collection)</param>
71+
/// <param name="controlName">Control name</param>
72+
/// <param name="dockStyle">Dock Style</param>
7173
/// <param name="inspectElementAtX">x coordinate (used for inspectElement)</param>
7274
/// <param name="inspectElementAtY">y coordinate (used for inspectElement)</param>
7375
/// <returns>Returns the <see cref="Control"/> that hosts the DevTools instance if successful, otherwise returns null on error.</returns>
@@ -92,6 +94,8 @@ public static Control ShowDevToolsDocked(this IChromiumWebBrowserBase chromiumWe
9294
/// Action that is Invoked when the DevTools Host Control has been created and needs to be added to it's parent.
9395
/// It's important the control is added to it's intended parent at this point so the <see cref="Control.ClientRectangle"/>
9496
/// can be calculated to set the initial display size.</param>
97+
/// <param name="controlName">control name</param>
98+
/// <param name="dockStyle">Dock Style</param>
9599
/// <param name="inspectElementAtX">x coordinate (used for inspectElement)</param>
96100
/// <param name="inspectElementAtY">y coordinate (used for inspectElement)</param>
97101
/// <returns>Returns the <see cref="Control"/> that hosts the DevTools instance if successful, otherwise returns null on error.</returns>

CefSharp.Wpf/Rendering/AllocHGlobalWritableBitmapRenderHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace CefSharp.Wpf.Rendering
1515
{
1616
/// <summary>
1717
/// AllocHGlobalWritableBitmapRenderHandler - creates/updates an WritableBitmap
18-
/// Uses <see cref="Marshal.AllocHGlobal"/> to allocate memory for
18+
/// Uses <see cref="Marshal.AllocHGlobal(int)"/> to allocate memory for
1919
/// double buffering when the size matches or creates a new WritableBitmap
2020
/// when required.
2121
/// </summary>

CefSharp.Wpf/Rendering/Experimental/CompositionTargetRenderHandler.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ public class CompositionTargetRenderHandler : IRenderHandler
2525
private readonly object lockObj = new object();
2626
private ChromiumWebBrowser browser;
2727

28+
/// <summary>
29+
/// Default constructor
30+
/// </summary>
31+
/// <param name="browser">ChromiumWebBrowser instance</param>
32+
/// <param name="dpiX">DPI X</param>
33+
/// <param name="dpiY">DPI Y</param>
2834
public CompositionTargetRenderHandler(ChromiumWebBrowser browser, double dpiX, double dpiY)
2935
{
3036
this.browser = browser;

CefSharp/Callback/NoOpCompletionCallback.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,22 @@ namespace CefSharp.Callback
1111
/// that does nothing with complete.
1212
/// Added to workaround a CEF bug as per https://github.com/cefsharp/CefSharp/issues/2957#issuecomment-555285400
1313
/// </summary>
14-
public class NoOpCompletionCallback : ICompletionCallback
14+
public sealed class NoOpCompletionCallback : ICompletionCallback
1515
{
16+
/// <inheritdoc/>
1617
void ICompletionCallback.OnComplete()
1718
{
1819

1920
}
2021

22+
/// <inheritdoc/>
2123
bool ICompletionCallback.IsDisposed
2224
{
2325
//For now we return false
2426
get { return false; }
2527
}
2628

29+
/// <inheritdoc/>
2730
void IDisposable.Dispose()
2831
{
2932

CefSharp/Callback/TaskCompletionCallback.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace CefSharp
1111
/// <summary>
1212
/// Provides a callback implementation of <see cref="ICompletionCallback"/>.
1313
/// </summary>
14-
public class TaskCompletionCallback : ICompletionCallback
14+
public sealed class TaskCompletionCallback : ICompletionCallback
1515
{
1616
private readonly TaskCompletionSource<bool> taskCompletionSource;
1717
private volatile bool isDisposed;

CefSharp/CefLibraryHandle.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public CefLibraryHandle(string path) : base(IntPtr.Zero, true)
5555
/// </value>
5656
public override bool IsInvalid
5757
{
58-
get { return this.handle == IntPtr.Zero; }
58+
get { return handle == IntPtr.Zero; }
5959
}
6060

6161
/// <summary>
@@ -67,7 +67,7 @@ public override bool IsInvalid
6767
/// </returns>
6868
protected override bool ReleaseHandle()
6969
{
70-
return FreeLibrary(this.handle);
70+
return FreeLibrary(handle);
7171
}
7272

7373
[DllImport("kernel32.dll", SetLastError = true)]

CefSharp/CefSharp.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
</ItemGroup>
2323
<ItemGroup>
2424
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" />
25+
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
26+
<PrivateAssets>all</PrivateAssets>
27+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
28+
</PackageReference>
2529
</ItemGroup>
2630
<ItemGroup>
2731
<Compile Remove="DevTools\DevToolsClient.Generated.netcore.cs" />

0 commit comments

Comments
 (0)