profile
viewpoint

lonix1/Middleware 0

Various ASP.NET Core middleware

issue closedHofmeisterAn/dotnet-testcontainers

[Feature Request] Report whether docker image exists locally

Is your feature request related to a problem? Please describe. When running container.StartAsync() for the first time, it needs to pull the image. This could take time, especially for large images, and on slow networks.

This happens during a test run, and because it's not obvious that it's happening, the assumption is often that something is "stuck" / buggy / whatever. So a <kbd>ctrl+c</kbd> is used, then a reattempt, then again, and so on, until one remembers that maybe a docker image is being pulled in the background! :-)

Describe the solution you'd like It would be nice to be able to log to the test console that the image is being pulled.

To do that though, the PostgreSqlTestcontainer (or whatever) needs to have a property/method that tells me if the "image exists". For example: container.ImageExists. Then I could do this:

var exists = container.ImageExists;
if (!exists) _logger.Log("About to pull image.");
await container.StartAsync();
if (!exists) _logger.Log("Image pulled (and container started).");

Describe alternatives you've considered no

Additional context no

closed time in 4 days

lonix1

issue commentHofmeisterAn/dotnet-testcontainers

[Feature Request] Report whether docker image exists locally

I don't have my integration tests setup that way, so it did not meet my needs, and I used a workaround instead. If anyone needs it what I did was this:

  • use Docker.DotNet library to determine if image exists
  • if not, log "pull begin"
  • pull/start image: await container.StartAsync()
  • log "pull end"

Enjoying this library, thanks for making it!

lonix1

comment created time in 4 days

issue closedHofmeisterAn/dotnet-testcontainers

[Question] Use existing container if it exists

I'm using this library to setup containers for integration tests for postgres. It works very well.

However it is slow to start and stop, as to be expected. So what I'm trying to achieve:

  • On my dev machine, I have another instance of postgres running (almost) all the time. If it is running then I'd like the library to use it.
  • On the test server, no containers would be running, so I'd like the library to start/stop throwaway containers as usual.

Is this possible somehow?

(I could add boilerplate code to detect if the container is running, etc,, but I'm hoping this library has functionality to do that?)

closed time in 4 days

lonix1

issue commentHofmeisterAn/dotnet-testcontainers

[Question] Use existing container if it exists

Understood, thanks.

For anyone who also needs this, what I did was:

  • use Docker.DotNet library to determine if container is running (1)
  • if not, create new container using this library (2)
  • grab connection string from (1) or (2)
lonix1

comment created time in 4 days

issue openedHofmeisterAn/dotnet-testcontainers

[Feature Request] Report whether docker image exists locally

Is your feature request related to a problem? Please describe. When running container.StartAsync() for the first time, it needs to pull the image. This could take time, especially for large images, and on slow networks.

This happens during a test run, and because it's not obvious that it's happening, the assumption is often that something is "stuck" / buggy / whatever. So a <kbd>ctrl+c</kbd> is used, then a reattempt, then again, and so on, until one remembers that maybe a docker image is being pulled in the background! :-)

Describe the solution you'd like It would be nice to be able to log to the test console that the image is being pulled.

To do that though, the PostgreSqlTestcontainer (or whatever) needs to have a property/method that tells me if the "image exists". For example: container.ImageExists. Then I could do this:

var exists = container.ImageExists;
if (!exists) _logger.Log("About to pull image.");
container.StartAsync();
if (!exists) _logger.Log("Image pulled (and container started).");

Describe alternatives you've considered no

Additional context no

created time in 4 days

issue openedHofmeisterAn/dotnet-testcontainers

Use existing container if it exists

I'm using this library to setup containers for integration tests for postgres. It works very well.

However it is slow to start and stop, as to be expected. So what I'm trying to achieve:

  • On my dev machine, I have another instance of postgres running (almost) all the time. If it is running then I'd like the library to use it.
  • On the test server, no containers would be running, so I'd like the library to start/stop throwaway containers as usual.

Is this possible somehow?

(I could add boilerplate code to detect if the container is running, etc,, but I'm hoping this library has functionality to do that?)

created time in 4 days

issue commentykoksen/unused-task-warning

Configure via editorconfig

there are two different rules.

I only knew of dotnet_diagnostic.LindhartAnalyserMissingAwaitWarning - which is the other one?

in Visual Studio by expanding the Analyser under references

I'm using vscode so I don't see that, but I don't mind using editorconfig though I find it easier.

lonix1

comment created time in 5 days

issue openedZaid-Ajaj/ThrowawayDb

Usage advice in integration tests

Hi @Zaid-Ajaj, I'm comparing this very nice library to "Respawn". I want to ensure I understand the differences - Respawn deletes data before/after a test run, whereas your library drops the complete database before/after a test run (or the entire test suite). Am I understanding correctly?

Also, I used to use rollback-able transactions in each test but ran into trouble. I'm trying to decide between your way which seems much cleaner, and the Respawn way which seems much faster. Is it simply a matter of speed? When would you advise to use the one or the other?

created time in 5 days

issue commentbjorkstromm/depends

Doesn't work for net5

Ok, maybe it's just my setup then. (I get the error in the original post above.)

lonix1

comment created time in 6 days

issue closedsuhay/vscode-editor-group-minimizer

Doesn't work when editor groups are vertical

When there are multiple editor groups open, vertically, it saves all of them into a single minimised group. Then closes everything!

And when restoring, they are restored in the wrong order, into two horizontal editor groups.

closed time in 7 days

lonix1

issue openedsuhay/vscode-editor-group-minimizer

Doesn't work when editor groups are vertical

When there are multiple editor groups open, vertically, it saves all of them into a single minimised group. Then closes everything!

And when restoring, they are restored in the wrong order, into two horizontal editor groups.

created time in 7 days

issue commentnsubstitute/NSubstitute

Prevent call to base class in constructor

Nothing we can do about it then, thanks.

lonix1

comment created time in 7 days

issue closednsubstitute/NSubstitute

Prevent call to base class in constructor

Consider this type that is outside my control:

public class Foo : FooBase {

  public Foo(IBar bar)
    : base(bar) {                       // <---- here's the problem
  }

  // other stuff...

}

I can do this: Substitute.ForPartsOf<Foo>(Substitute.For<IBar>()). But it calls the base class' constructor, so everything breaks.

I thought I could use some DoNotCallBase magic or something similar, but couldn't find a way.

Is there some trick for handling this situation? If not, I'll rethink and redesign.

Thanks!

closed time in 7 days

lonix1

issue commentbjorkstromm/depends

Doesn't work for net5

Sorry only saw this now. @amaechler Does it work for you on net5? I tried your fix but it still looks for 3.1 and ignores 5.0. Anything I must do to force it to pick up my net5 sdk?

lonix1

comment created time in 7 days

issue commentfluentassertions/fluentassertions

Very easy to misuse `ThrowAsync` in a sync test

Amazing how many tests I was able to fix with ykoksen/unused-task-warning.

@dennisdoomen, @jnyrup I realise this is out of scope, but if there is a way to bring attention to this issue in the docs, it would help other users, and that library is the perfect solution. Just a thought. My original assertion (pun intended) that it is a common problem still holds.

Thanks again @jnyrup.

lonix1

comment created time in 8 days

issue openedSuchiman/SerilogAnalyzer

Development only nuget asset?

The docs show this:

<PackageReference Include="SerilogAnalyzer" Version="0.15.0" />

Is the following supported?

<PackageReference Include="SerilogAnalyzer" Version="0.15.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

created time in 8 days

issue closedykoksen/unused-task-warning

Configure via editorconfig

Firstly, thanks for making this library... it really helped me clean up my code! :smiley:

With other analyser rules I can control them in .editorconfig like this:

dotnet_diagnostic.CA1012.severity = warning

How do I do that for this analyser rule? What is its code?

closed time in 8 days

lonix1

issue commentykoksen/unused-task-warning

Configure via editorconfig

Ok, I figured it out:

dotnet_diagnostic.LindhartAnalyserMissingAwaitWarning.severity = warning

I assume the default is warning? It can be changed to error, warning, suggestion, silent, none, default.

lonix1

comment created time in 8 days

issue openedykoksen/unused-task-warning

Configure via editorconfig

Firstly, thanks for making this library... it really helped me clean up my code! :smiley:

With other analyser rules I can control them in .editorconfig like this:

dotnet_diagnostic.CA1012.severity = warning

How do I do that for this analyser rule? What is its code?

created time in 8 days

issue closedfluentassertions/fluentassertions

Very easy to misuse `ThrowAsync` in a sync test

Description

The API for asserting exceptions in async code is VERY easy to misuse. Such tests would pass, but in fact should fail.

The problem is that action.Should().ThrowAsync<Exception>() should be awaited, but Roslyn doesn't know that and doesn't warn you. It's very easy to forget to put it in an async test, and to await it.

Complete minimal example reproducing the issue

This test has a very subtle hard-to-detect bug. It should fail, but will actually pass.

[Fact]
public void sync_test_that_should_fail_but_will_pass()
{
    Func<Task> action = () => throw new ArgumentNullException("paramName");
    action.Should().ThrowAsync<ArgumentNullException>().WithParameterName("foo");     // "foo" is incorrect
}

This test fixes the bug. It should fail, and will fail.

[Fact]
public async Task async_test_that_should_fail_and_will_fail()
{
    Func<Task> action = () => throw new ArgumentNullException("paramName");
    await action.Should().ThrowAsync<ArgumentNullException>().WithParameterName("foo");
}

Expected behavior:

Don't know! :smile:

Firstly please tell me, are you aware of an analyser (third party maybe?) that checks for this?

If not, there are two options:

  • Maybe someone someday will write an analyser that detects this problem. That would be best. It would see that you don't await when calling a ThrowsAsync. I know nothing about Roslyn so regrettably cannot assist.
  • Is it possible to detect this at runtime and log a warning to the console?

Actual behavior:

Doesn't warn you.

Versions

  • Which version of Fluent Assertions are you using? 6.2.0
  • Which .NET runtime and version are you targeting? .NET Core 5

Additional Information

Maybe there's a different way to handle this problem - if so I'd appreciate the advice!

closed time in 8 days

lonix1

issue commentfluentassertions/fluentassertions

Very easy to misuse `ThrowAsync` in a sync test

If your method is marked as async CS4014 detects non-awaited methods.

True, but the problem is when you don't realise, and you write a sync test instead (like in my first example). Then the analyser won't be triggered.

A post on SO suggested ykoksen/unused-task-warning I haven't tried it, but I'ld like to hear your experiences.

Thanks - I tried ykoksen/unused-task-warning as an analyser and it works well! Very clever little library.

Then I tried semihokur/AsyncFixer which has some interesting analysers and that works well too!

I strongly recommend both of these libraries, I've already found lots of places to improve in my code. Thanks for sending me in the right direction.

lonix1

comment created time in 8 days

issue openedfluentassertions/fluentassertions

Very easy to misuse `ThrowAsync` in a sync test

Description

The API for asserting exceptions in async code is VERY easy to misuse. Such tests would pass, but in fact should fail.

The problem is that action.Should().ThrowAsync<Exception>() should be awaited, but Roslyn doesn't know that and doesn't warn you. It's very easy to forget to put it in an async test, and to await it.

Complete minimal example reproducing the issue

This test has a very subtle hard-to-detect bug. It should fail, but will actually pass.

[Fact]
public void sync_test_that_should_fail_but_will_pass() {
  Func<Task> action = () => throw new ArgumentNullException("paramName");
  action.Should().ThrowAsync<ArgumentNullException>().WithParameterName("foo");     // "foo" is incorrect
}

This test fixes the bug. It should fail, and will fail.

[Fact]
public async Task async_test_that_should_fail_and_will_fail() {
  Func<Task> action = () => throw new ArgumentNullException("paramName");
  await action.Should().ThrowAsync<ArgumentNullException>().WithParameterName("foo");
}

Expected behavior:

Don't know! :smile:

Firstly please tell me, are you aware of an analyser (third party maybe?) that checks for this?

If not, there are two options:

  • Maybe someone someday will write an analyser that detects this problem. That would be best. It would see that you don't await when calling a ThrowsAsync. I know nothing about Roslyn so regrettably cannot assist.
  • Is it possible to detect this at runtime and log a warning to the console?

Actual behavior:

Doesn't warn you.

Versions

  • Which version of Fluent Assertions are you using? 6.2.0
  • Which .NET runtime and version are you targeting? .NET Core 5

Additional Information

Maybe there's a different way to handle this problem - if so I'd appreciate the advice!

created time in 8 days

issue commenttakkaO/VSCode-OpenWindowTabContext

Location of "Open in new window" at top/bottom

It works nicely - thanks. And I like the new auto-close feature.

We can close this issue now?

lonix1

comment created time in 9 days

issue commentOmniSharp/omnisharp-vscode

After single test debug, Omnisharp "crashes" silently

@msigut If you have one test that consistently crashes then you are luckier than the rest of us, because this bug is hard to reproduce. Check whether the crash is always for the same reason. If so consider posting your crash log here so the devs can look at it?

falquan

comment created time in 9 days

issue openedsmulyono/reveal-file-ext

[Feature Request] Button in explorer

@smulyono The button is shown for the active document.

Is it possible to also show a button in the explorer sidebar? (Next to "new file", "new folder", "refresh", "collapse" buttons).

created time in 9 days

issue commentnpgsql/efcore.pg

Log PostgreSQL NOTICE messages via EF Core's logging mechanism

Thanks for answering that question on SO. But this issue confused me a bit - I went into the docs and found this very sophisticated logging behaviour. The logging you mention above, will it replace that?

roji

comment created time in 10 days

issue openednsubstitute/NSubstitute

Prevent call to base class in constructor

Consider this type that is outside my control:

public class Foo {

  public Foo(IBar bar)
    : base(bar) {                       // <---- here's the problem
  }

  // other stuff...

}

I can do this: Substitute.ForPartsOf<Foo>(Substitute.For<IBar>()). But the ctor calls the base class ctor, so everything breaks.

I thought I could use some DoNotCallBase magic or something similar, but couldn't find a way.

Is there some trick for handling this situtation? If not, I'll rethink and redesign.

Thanks!

created time in 10 days

issue commentdotnet/roslyn-analyzers

CA1062 reporting for protected and internal methods

I suppose you're right.

But, I tend to test args for internal as well. I think the boundary is not the assembly, but rather the developer who's using it. In a team when multiple people work on the same assembly, one guy blows up the other guy's code. So I always test internal args as well.

I guess we can close this as "by design"?

lonix1

comment created time in 11 days

issue commentdotnet/roslyn-analyzers

CA1062 reporting for protected and internal methods

I think you are right. But in that case why not trigger the analyser for both cases?

Within an assembly, an internal method is as good as public. So surely is should also trigger the analyser?

lonix1

comment created time in 11 days

issue commentnsubstitute/NSubstitute.Analyzers

NS2002 falsely triggered by optional ctor args

Your idea of a more descriptive warning is good. It will let the user know that it is "normal" and there is nothing he can do about it.

lonix1

comment created time in 11 days

more