Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning fixes #14894

Merged
merged 4 commits into from
Mar 9, 2024
Merged

Warning fixes #14894

merged 4 commits into from
Mar 9, 2024

Conversation

MrJul
Copy link
Member

@MrJul MrJul commented Mar 9, 2024

What does the pull request do?

Another batch of warning fixes:

  • Fixes XML doc warnings (again)
  • Fixes CA1854: use Dictionary.TryGetValue instead of ContainsKey+indexer
  • Fixes CS9123: avoid & in async methods
  • Use SetCurrentValue to set DataGridColumn.Width

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0045994-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 added this pull request to the merge queue Mar 9, 2024
Merged via the queue into AvaloniaUI:master with commit 1f75386 Mar 9, 2024
6 checks passed
@MrJul MrJul deleted the warning-fixes branch March 9, 2024 23:55
@@ -325,16 +325,16 @@ async Task SendFrame(FrameType type, byte[] data, int offset, int length)

const byte endOfMessageBit = (byte)1u << 7;
header.Mask = (byte) (endOfMessageBit | ((byte) type & 0xf));
unsafe
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably use span casts instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was actually what I tried first, but I found the resulting code not buying much:

MemoryMarshal.AsBytes(new Span<WebSocketHeader>(&source, 1))
    .Slice(0, headerLength)
    .CopyTo(destination);

Not even saving the pointer usage to be compatible with .NET Standard.
That's basically the implementation of Marshal.Copy, so I didn't bother.

If the struct didn't have a variable size, we could simply use MemoryMarshal.Write(destination, ref header) instead: clear and concise. At that point, since we need 3 different structs, we're probably better writing directly to the destination buffer using BinaryPrimitives.WriteX().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants