LordKalma (CT7ALW)
LordKalma (CT7ALW)
CC#
Created by gameyall232 on 12/5/2023 in #help
Any way to get XAML Auto-complete in VS Code?
You can try rogalmic.vscode-xml-complete if you configure the schema...
17 replies
CC#
Created by gameyall232 on 12/5/2023 in #help
Any way to get XAML Auto-complete in VS Code?
have you built the project at least once?
17 replies
CC#
Created by LordKalma (CT7ALW) on 12/6/2023 in #help
Smart enums, inheritance and "siblings" behaving weirdly and I don't understand why.
thanks for the time for the deep dive!
19 replies
CC#
Created by LordKalma (CT7ALW) on 12/6/2023 in #help
Smart enums, inheritance and "siblings" behaving weirdly and I don't understand why.
pun totally intended
19 replies
CC#
Created by LordKalma (CT7ALW) on 12/6/2023 in #help
Smart enums, inheritance and "siblings" behaving weirdly and I don't understand why.
but yeah, seems that Ardalis.SmartEnum is a smartely crafted library
19 replies
CC#
Created by LordKalma (CT7ALW) on 12/6/2023 in #help
Smart enums, inheritance and "siblings" behaving weirdly and I don't understand why.
yes yes, that's why I'm saying, it was just "hey, this symbol is available from here"
19 replies
CC#
Created by LordKalma (CT7ALW) on 12/6/2023 in #help
Smart enums, inheritance and "siblings" behaving weirdly and I don't understand why.
yes that, sorry
19 replies
CC#
Created by LordKalma (CT7ALW) on 12/6/2023 in #help
Smart enums, inheritance and "siblings" behaving weirdly and I don't understand why.
VS recommended to just put List in there, no prefix
19 replies
CC#
Created by LordKalma (CT7ALW) on 12/6/2023 in #help
Smart enums, inheritance and "siblings" behaving weirdly and I don't understand why.
ah because List is a static member and that is shared when they aren't generic, got it
19 replies
CC#
Created by LordKalma (CT7ALW) on 12/6/2023 in #help
Smart enums, inheritance and "siblings" behaving weirdly and I don't understand why.
This looks like it makes some use of reflection, so having all of that in the static analyser is kind of amazing
19 replies
CC#
Created by LordKalma (CT7ALW) on 12/6/2023 in #help
Smart enums, inheritance and "siblings" behaving weirdly and I don't understand why.
What amazes me the most after all of this is that the static analyser picked up that the .List would be the same
19 replies
CC#
Created by LordKalma (CT7ALW) on 12/6/2023 in #help
Smart enums, inheritance and "siblings" behaving weirdly and I don't understand why.
Thanks for the deep dive! Wow!
19 replies
CC#
Created by LordKalma (CT7ALW) on 12/6/2023 in #help
Smart enums, inheritance and "siblings" behaving weirdly and I don't understand why.
CHIP = new(nameof(CHIP), null);
CHIP = new(nameof(CHIP), null);
and
[Test]
public void DifferentModesHaveDifferentSubModes()
{
var chip64 = Mode.CHIP.Submodes;
Assert.Multiple(() =>
{
Assert.That(chip64, Is.Null);
});
}
[Test]
public void DifferentModesHaveDifferentSubModes()
{
var chip64 = Mode.CHIP.Submodes;
Assert.Multiple(() =>
{
Assert.That(chip64, Is.Null);
});
}
` Does solve it, yeah
19 replies
CC#
Created by LordKalma (CT7ALW) on 12/6/2023 in #help
Smart enums, inheritance and "siblings" behaving weirdly and I don't understand why.
I also thought that probably a single member it should work, but apparently not?
19 replies
CC#
Created by LordKalma (CT7ALW) on 12/6/2023 in #help
Smart enums, inheritance and "siblings" behaving weirdly and I don't understand why.
With
public sealed class Mode : ModeBase
{
public static readonly Mode CHIP = new(nameof(CHIP), ChipSubMode.List);
// public static readonly Mode CW = new(nameof(CW), "Morse (CW)", CwSubMode.List);
public sealed class Mode : ModeBase
{
public static readonly Mode CHIP = new(nameof(CHIP), ChipSubMode.List);
// public static readonly Mode CW = new(nameof(CW), "Morse (CW)", CwSubMode.List);
and
[Test]
public void DifferentModesHaveDifferentSubModes()
{
var chip64 = Mode.CHIP.Submodes?.First().Name;
// var pcw = Mode.CW.Submodes?.First().Name;
Assert.Multiple(() =>
{
Assert.That(chip64, Is.EqualTo("CHIP64"));
// Assert.That(pcw, Is.EqualTo("PCW"));
});
}
}
[Test]
public void DifferentModesHaveDifferentSubModes()
{
var chip64 = Mode.CHIP.Submodes?.First().Name;
// var pcw = Mode.CW.Submodes?.First().Name;
Assert.Multiple(() =>
{
Assert.That(chip64, Is.EqualTo("CHIP64"));
// Assert.That(pcw, Is.EqualTo("PCW"));
});
}
}
The test still fails
Message:  System.TypeInitializationException : The type initializer for 'AetherLogger.Models.Mode' threw an exception. ----> System.NullReferenceException : Object reference not set to an instance of an object. Stack Trace:  ModeTests.DifferentModesHaveDifferentSubModes() line 9 RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor) MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr) --NullReferenceException <>c.<GetAllOptions>b4_2(TEnum t) EnumerableSorter2.ComputeKeys(TElement[] elements, Int32 count) EnumerableSorter1.ComputeMap(TElement[] elements, Int32 count) EnumerableSorter1.Sort(TElement[] elements, Int32 count) OrderedEnumerable1.Fill(Buffer1 buffer, Span1 destination) OrderedEnumerable1.ToArray() SmartEnum2.GetAllOptions() Lazy1.ViaFactory(LazyThreadSafetyMode mode) Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) Lazy`1.CreateValue() <.cctor>b36_0() Lazy1.ViaFactory(LazyThreadSafetyMode mode) Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) Lazy1.CreateValue() SmartEnum2.get_List() Mode.cctor() line 23
19 replies
CC#
Created by LordKalma (CT7ALW) on 12/6/2023 in #help
Smart enums, inheritance and "siblings" behaving weirdly and I don't understand why.
Message:  System.TypeInitializationException : The type initializer for 'AetherLogger.Models.Mode' threw an exception. ----> System.NullReferenceException : Object reference not set to an instance of an object. Stack Trace:  ModeTests.DifferentModesHaveDifferentSubModes() line 9 RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor) MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr) --NullReferenceException <>c.<GetAllOptions>b4_2(TEnum t) EnumerableSorter2.ComputeKeys(TElement[] elements, Int32 count) EnumerableSorter1.ComputeMap(TElement[] elements, Int32 count) EnumerableSorter1.Sort(TElement[] elements, Int32 count) OrderedEnumerable1.Fill(Buffer1 buffer, Span1 destination) OrderedEnumerable1.ToArray() SmartEnum2.GetAllOptions() Lazy1.ViaFactory(LazyThreadSafetyMode mode) Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) Lazy`1.CreateValue() <.cctor>b36_0() Lazy1.ViaFactory(LazyThreadSafetyMode mode) Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) Lazy1.CreateValue() SmartEnum2.get_List() Mode.cctor() line 23
19 replies
CC#
Created by LordKalma (CT7ALW) on 12/6/2023 in #help
Smart enums, inheritance and "siblings" behaving weirdly and I don't understand why.
Doing this the following test is completly broken:
[TestFixture]
public class ModeTests
{
[Test]
public void DifferentModesHaveDifferentSubModes()
{
var chip64 = Mode.CHIP.Submodes?.First().Name;
var pcw = Mode.CW.Submodes?.First().Name;
Assert.Multiple(() =>
{
Assert.That(chip64, Is.EqualTo("CHIP64"));
Assert.That(pcw, Is.EqualTo("PCW"));
});
}
}
[TestFixture]
public class ModeTests
{
[Test]
public void DifferentModesHaveDifferentSubModes()
{
var chip64 = Mode.CHIP.Submodes?.First().Name;
var pcw = Mode.CW.Submodes?.First().Name;
Assert.Multiple(() =>
{
Assert.That(chip64, Is.EqualTo("CHIP64"));
Assert.That(pcw, Is.EqualTo("PCW"));
});
}
}
With the error:
System.TypeInitializationException : The type initializer for 'AetherLogger.Models.Mode' threw an exception. ----> System.NullReferenceException : Object reference not set to an instance of an object.
And I don't know which bit of the language I don't understand that causes this error. I would like to learn. Thank you.
19 replies
CC#
Created by LordKalma (CT7ALW) on 12/6/2023 in #help
Smart enums, inheritance and "siblings" behaving weirdly and I don't understand why.
No description
19 replies
CC#
Created by LordKalma (CT7ALW) on 12/6/2023 in #help
Smart enums, inheritance and "siblings" behaving weirdly and I don't understand why.
This does not work:
using Ardalis.SmartEnum;

namespace AetherLogger.Models;

public interface IModeInterface : ISmartEnum
{
string ReadableName { get; }
}

public abstract class ModeBase : SmartEnum<ModeBase>, IModeInterface
{
protected ModeBase(string name, string? readableName = null) : base(name, ++_counter)
{
ReadableName = readableName ?? name;
}

private static int _counter;
public string ReadableName { get; }
}

public sealed class Mode : ModeBase
{
public static readonly Mode CHIP = new(nameof(CHIP), ChipSubMode.List);
public static readonly Mode CW = new(nameof(CW), "Morse (CW)", CwSubMode.List);

public IEnumerable<IModeInterface>? Submodes { get; }

private Mode(string name, string? readableName = null, IEnumerable<IModeInterface>? submodes = null) : base(name, readableName)
{
Submodes = submodes;
}

public Mode(string name, IEnumerable<IModeInterface> submodes) : this(name, name, submodes)
{
}
}


public sealed class ChipSubMode(string name, string? readableName = null) : ModeBase(name, readableName)
{
public static readonly ChipSubMode CHIP64 = new(nameof(CHIP64), "CHIP 64");
public static readonly ChipSubMode CHIP128 = new(nameof(CHIP128), "CHIP 128");
}

public sealed class CwSubMode(string name, string? readableName = null) : ModeBase(name, readableName)
{
public static readonly CwSubMode PCW = new(nameof(PCW), "Precision CW");
}
using Ardalis.SmartEnum;

namespace AetherLogger.Models;

public interface IModeInterface : ISmartEnum
{
string ReadableName { get; }
}

public abstract class ModeBase : SmartEnum<ModeBase>, IModeInterface
{
protected ModeBase(string name, string? readableName = null) : base(name, ++_counter)
{
ReadableName = readableName ?? name;
}

private static int _counter;
public string ReadableName { get; }
}

public sealed class Mode : ModeBase
{
public static readonly Mode CHIP = new(nameof(CHIP), ChipSubMode.List);
public static readonly Mode CW = new(nameof(CW), "Morse (CW)", CwSubMode.List);

public IEnumerable<IModeInterface>? Submodes { get; }

private Mode(string name, string? readableName = null, IEnumerable<IModeInterface>? submodes = null) : base(name, readableName)
{
Submodes = submodes;
}

public Mode(string name, IEnumerable<IModeInterface> submodes) : this(name, name, submodes)
{
}
}


public sealed class ChipSubMode(string name, string? readableName = null) : ModeBase(name, readableName)
{
public static readonly ChipSubMode CHIP64 = new(nameof(CHIP64), "CHIP 64");
public static readonly ChipSubMode CHIP128 = new(nameof(CHIP128), "CHIP 128");
}

public sealed class CwSubMode(string name, string? readableName = null) : ModeBase(name, readableName)
{
public static readonly CwSubMode PCW = new(nameof(PCW), "Precision CW");
}
(note that now we have ModeBase : SmartEnum<ModeBase>, IModeInterface)
19 replies
CC#
Created by LordKalma (CT7ALW) on 4/29/2023 in #help
❔ Capturing value-types by value (i.e., making a copy) in λs. Or rather, using a Span<T> in a λ.
I like views over memory, thank you 🙂
11 replies