cap5lut
cap5lut
CC#
Created by cap5lut on 4/15/2024 in #help
vectorizable algorithms/excercises
his is not a question about how it works: I wanna learn more about vectorization and am looking for some algorithms which can be vectorized. I do not want solutions, but a list problems that can be solved and sped up using vectorization to train myself. I have same basic understanding on how it works. eg, i can write a sum algorithm, but thats more or less it because i never really had something where i could apply it and my googling skills regarding this are quite bad. so , im searching from the beginner friendly up to the advanced stuff. do u have some ideas/lists/resources, please tell me 🙂
3 replies
CC#
Created by cap5lut on 4/1/2023 in #help
✅ VS2022 | Enable missing xml docs warnings for non-public API
Hi, after searching for a while and digging throw Vs2022, this is now my last resort. Basically I want a warning like CS1591, but for the non public stuff. Is there something like that or do I have to write an analyzer for that?
1 replies
CC#
Created by cap5lut on 3/30/2023 in #help
✅ Make method implemented in interface accessible from implementing type
i have an interface
interface ICL
{
public IEnumerable<ICLPlatform> GetPlatforms()
{
// code
}
}
interface ICL
{
public IEnumerable<ICLPlatform> GetPlatforms()
{
// code
}
}
and an implementing struct
struct CLAdapter : ICL
{
}
struct CLAdapter : ICL
{
}
now GetPlatforms() isnt reachable via new CLAdapter().GetPlatforms(), how can i make that accessible? i tried implementing it in the adapter by simply casting this to ICL, but then i run into stack overflows
/// <inheritdoc/>
public IEnumerable<ICLPlatform> GetPlatforms()
{
return ((ICL)this).GetPlatforms();
}
/// <inheritdoc/>
public IEnumerable<ICLPlatform> GetPlatforms()
{
return ((ICL)this).GetPlatforms();
}
7 replies
CC#
Created by cap5lut on 3/26/2023 in #help
❔ Unit Test | Mocking class with unsafe methods
Hi, I am having trouble writing unit tests, because I dont know how to mock/setup the underlying instance/its methods. The class Silk.NET.OpenCL.CL (https://github.com/dotnet/Silk.NET/blob/main/src/OpenCL/Silk.NET.OpenCL/CL.gen.cs) does not implement an interface and the methods are unsafe and non virtual. This would be one of the methods I need to mock:
public unsafe int GetPlatformIDs(uint num_entries, nint* platforms, out uint num_platforms);
public unsafe int GetPlatformIDs(uint num_entries, nint* platforms, out uint num_platforms);
(instead of out uint num_platforms I could also use uint* num_platforms, if that matters) I tried using Moq, but I run into errors for the null pointer and count parameter:
unsafe
{
var cl = new Mock<CL>();
cl.Setup(instance => instance.GetPlatformIDs(0, null, out var count)).Returns(0);
// ....
}
unsafe
{
var cl = new Mock<CL>();
cl.Setup(instance => instance.GetPlatformIDs(0, null, out var count)).Returns(0);
// ....
}
CS1944: An expression tree may not contain an unsafe pointer operation CS8198: An expression tree may not contain an out argument variable declaration
( I tried also other libraries like Pose, but they all use System.Linq.Expressions.Expression so I always ran into the same errors) Any idea how to do that?
4 replies
CC#
Created by cap5lut on 12/1/2022 in #help
❔ AvaloniaUI InvalidCastException
I started playing around with AvaloniaUI and I get a InvalidCastExceptions. the MainWindow's XAML:
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:main="clr-namespace:cap5lut.net.Growbox.Client.Views.Main"
xmlns:controls="clr-namespace:cap5lut.net.Growbox.Client.Controls"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="cap5lut.net.Growbox.Client.Views.Main.MainWindow"
x:DataType="main:MainWindowViewModel"
x:CompileBindings="True"
Title="{Binding Title}">
<controls:ServerAddForm
DataContext="{Binding ServerAddForm}"/>
</Window>
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:main="clr-namespace:cap5lut.net.Growbox.Client.Views.Main"
xmlns:controls="clr-namespace:cap5lut.net.Growbox.Client.Controls"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="cap5lut.net.Growbox.Client.Views.Main.MainWindow"
x:DataType="main:MainWindowViewModel"
x:CompileBindings="True"
Title="{Binding Title}">
<controls:ServerAddForm
DataContext="{Binding ServerAddForm}"/>
</Window>
the MainWindowViewModel:
public class MainWindowViewModel : Model
{
private string _title;
private ServerAddFormModel _serverAddForm;

public MainWindowViewModel()
{
_title = $"Servers - Growbox - v{Assembly.GetExecutingAssembly().GetName().Version} - cap5lut.net";
_serverAddForm = new ServerAddFormModel();
}

public string Title
{
get => _title;
set => SetField(ref _title, value);
}

public ServerAddFormModel ServerAddForm
{
get => _serverAddForm;
set => SetField(ref _serverAddForm, value);
}
}
public class MainWindowViewModel : Model
{
private string _title;
private ServerAddFormModel _serverAddForm;

public MainWindowViewModel()
{
_title = $"Servers - Growbox - v{Assembly.GetExecutingAssembly().GetName().Version} - cap5lut.net";
_serverAddForm = new ServerAddFormModel();
}

public string Title
{
get => _title;
set => SetField(ref _title, value);
}

public ServerAddFormModel ServerAddForm
{
get => _serverAddForm;
set => SetField(ref _serverAddForm, value);
}
}
(Model is just an INotifyPropertyChanged implementation)
7 replies
CC#
Created by cap5lut on 10/25/2022 in #help
UDP Multicast does not work as expected [Answered]
I am starting to play around with UDP for some IPC stuff and wrote a simple UDP Multicast application just to have a playground to advance from, but sadly its not going as expected. First of all: here is the code of the small program https://gist.github.com/cap5lut/ce3bfda6a0997b647a67a20d78d9e189 My expectation was that the writer sends the data and both readers would receive the data, resulting in an output like
writer: sending 5
reader 1: read 5
reader 2: read 5
writer: sending 5
reader 1: read 5
reader 2: read 5
but that is not the case, only the writer and reader 1 is spitting out stuff. what am I doing wrong?
13 replies