realivanjxツ
realivanjxツ
CC#
Created by realivanjxツ on 6/8/2023 in #help
❔ unsafe pointer operation
hi. im trying to rewrite code from other c# project to restore the sanity back. there is this one part that i dont quite understand:
byte[] arr = ...;
byte* buffer = arr;
var x = *buffer++; // actual line is much more complicated operations than this
byte[] arr = ...;
byte* buffer = arr;
var x = *buffer++; // actual line is much more complicated operations than this
what does the *buffer++ do? is it equal to buffer[index++] or buffer[index]++. thanks.
10 replies
CC#
Created by realivanjxツ on 4/17/2023 in #help
❔ change timezone of aspnet docker container
how to change aspnet docker container's timezone? i am using this image mcr.microsoft.com/dotnet/aspnet:7.0.5-jammy. i already tried changing the TZ variable in my docker compose but it is still showing UTC. thanks
4 replies
CC#
Created by realivanjxツ on 1/8/2023 in #help
✅ httpclient get download stream in blazor
i have this code to download a file from remote source (about 100 MB).
HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Get, REMOTE_URL);
HttpResponseMessage responseMessage = await Http.SendAsync(
requestMessage,
HttpCompletionOption.ResponseHeadersRead);
using Stream remoteStream = await responseMessage.Content.ReadAsStreamAsync();
byte[] buffer = new byte[1024 * 1024];

while (CurrentProgress < MaxProgress)
{
int read = await remoteStream.ReadAsync(
buffer,
0,
buffer.Length);
CurrentProgress += read;
StateHasChanged();
}
HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Get, REMOTE_URL);
HttpResponseMessage responseMessage = await Http.SendAsync(
requestMessage,
HttpCompletionOption.ResponseHeadersRead);
using Stream remoteStream = await responseMessage.Content.ReadAsStreamAsync();
byte[] buffer = new byte[1024 * 1024];

while (CurrentProgress < MaxProgress)
{
int read = await remoteStream.ReadAsync(
buffer,
0,
buffer.Length);
CurrentProgress += read;
StateHasChanged();
}
but it seems that that code above downloads the whole file first at line using Stream remoteStream so i cant really show any progress to the gui. is this a bug with the blazor's httpclient implementation because the code works fine on my wpf app. thanks
5 replies
CC#
Created by realivanjxツ on 12/23/2022 in #help
❔ xunit field scope
lets say i have a class for unit testing below:
class Tests
{
Dependency dep1;

public Tests()
{
dep1 = new Dependency();
}

[Fact]
public void test1()
{
Service s1 = new Service(dep1);
...
}

[Fact]
public void test2()
{
Service s2 = new Service(dep1);
...
}
}
class Tests
{
Dependency dep1;

public Tests()
{
dep1 = new Dependency();
}

[Fact]
public void test1()
{
Service s1 = new Service(dep1);
...
}

[Fact]
public void test2()
{
Service s2 = new Service(dep1);
...
}
}
will s1 and s2 have the same dep1 instance or will they get different ones? thanks
5 replies
CC#
Created by realivanjxツ on 12/22/2022 in #help
❔ Path.GetFullPath behavior on linux
17 replies
CC#
Created by realivanjxツ on 12/20/2022 in #help
❔ StreamWriter weird output
3 replies
CC#
Created by realivanjxツ on 11/10/2022 in #help
❔ system.text.json source generator in net standard
is it possible to use stj's source generator inside a net standard project (i dont mind 2.1)? according to this https://devblogs.microsoft.com/dotnet/try-the-new-system-text-json-source-generator/ source generator is supported in net standard project
3 replies
CC#
Created by realivanjxツ on 11/10/2022 in #help
❔ yaml parser with native aot
is there any yaml parser library that supports native aot? i tried yamldotnet but it doesnt work with native aot because it uses system.reflection a lot. thanks
3 replies
CC#
Created by realivanjxツ on 11/8/2022 in #help
how to use ReflectionAnalyzers
how to check for reflection warnings in my project (net standard 2.0)? it uses some other nuget packages. i want to include this net standard library to my native aot compiled app. thanks.
1 replies
CC#
Created by realivanjxツ on 11/7/2022 in #help
inter process communication
what is the easiest and most performant way to communicate between 2 c# applications in the same machine? one of them is a wpf app and the other one is a command line app.
9 replies
CC#
Created by realivanjxツ on 10/1/2022 in #help
rar library
what is the best library/nuget out there to list and extract the content of a rar file? it would be better if it is specifically for rar since i already able to work with zip files via the built in ZipArchive class. thanks.
33 replies