Skip to content

Commit

Permalink
Remove ref and readonly from generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
ThadHouse committed Feb 22, 2024
1 parent e273f5e commit 97b434c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
4 changes: 1 addition & 3 deletions codehelp/CodeHelpers/TypeDeclarationModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ public record TypeDeclarationModel(TypeKind Kind, TypeModifiers Modifiers, strin
{
private string GetClassDeclaration(bool addUnsafe)
{
string readonlyString = (Modifiers & TypeModifiers.IsReadOnly) != 0 ? "readonly " : "";
string refString = (Modifiers & TypeModifiers.IsRefLikeType) != 0 ? "ref " : "";
string recordString = (Modifiers & TypeModifiers.IsRecord) != 0 ? "record " : "";
string unsafeString = addUnsafe ? "unsafe " : "";
#pragma warning disable CS8509 // The switch expression does not handle all possible values of its input type (it is not exhaustive).
Expand All @@ -29,7 +27,7 @@ private string GetClassDeclaration(bool addUnsafe)
};
#pragma warning restore CS8509 // The switch expression does not handle all possible values of its input type (it is not exhaustive).

return $"{unsafeString}{readonlyString}{refString}partial {recordString}{kindString}";
return $"{unsafeString}partial {recordString}{kindString}";
}

private void GetGenericParameters(IndentedStringBuilder builder)
Expand Down
1 change: 0 additions & 1 deletion src/wpilibsharp/DataLogManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public static class DataLogManger
private static NtConnectionDataLogger m_ntConnLogger;
private static StringLogEntry? m_messageLog;
private static readonly object m_lockObject = new();
private static volatile int m_runThread = 1;

// if less than this much free space, delete log files until there is this much free space
// OR there are this many files remaining.
Expand Down
5 changes: 3 additions & 2 deletions src/wpiutil/Concurrent/RefEvent.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using WPIUtil.Handles;
using WPIUtil.Natives;

namespace WPIUtil.Concurrent;

public readonly ref struct RefEvent
{
public int Handle { get; }
public WpiEventHandle Handle { get; }

public readonly void Dispose()
{
if (Handle != 0)
if (Handle.Handle != 0)
{
SynchronizationNative.DestroyEvent(Handle);
}
Expand Down
3 changes: 2 additions & 1 deletion src/wpiutil/EventVector.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using WPIUtil.Handles;
using WPIUtil.Natives;

namespace WPIUtil;
Expand Down Expand Up @@ -29,7 +30,7 @@ public void Wakeup()
{
foreach (int handle in m_events)
{
SynchronizationNative.SetEvent(handle);
SynchronizationNative.SetEvent(new WpiEventHandle(handle));
}
}
}
Expand Down

0 comments on commit 97b434c

Please sign in to comment.