Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dropping default ValueTask #49

Merged
merged 10 commits into from
Jan 26, 2024
Merged

Conversation

GerardSmit
Copy link
Contributor

@GerardSmit GerardSmit commented Jan 25, 2024

This PR fixes dropping ValueTask.CompletedTask, default (when the return type is ValueTask) and new ValueTask<T>(...).

ValueTask

Before

ValueTask.CompletedTask

public static ValueTask DoSomethingAsync() { return ValueTask.CompletedTask; }
public static ValueTask DoSomethingAsync() { return ValueTask.CompletedTask; Console.WriteLine(\"123\"); }
public static ValueTask DoSomethingAsync() => ValueTask.CompletedTask;

// -->

public static void DoSomething() { return global::System.Threading.Tasks.ValueTask.CompletedTask; }

Default

public static ValueTask DoSomethingAsync() { return default; }

// -->

public static void DoSomething() { return default; }

New

public static ValueTask DoSomethingAsync() { return new(); }

// -->

public static void DoSomething() { return new(); }

After (PR)

public static ValueTask DoSomethingAsync() { return ValueTask.CompletedTask; }
public static ValueTask DoSomethingAsync() { return ValueTask.CompletedTask; Console.WriteLine(\"123\"); }
public static ValueTask DoSomethingAsync() => ValueTask.CompletedTask;
public static ValueTask DoSomethingAsync() { return default; }
public static ValueTask DoSomethingAsync() { return new(); }

// -->

public static void DoSomething() { }

ValueTask<T>

Before

public static ValueTask<int> ReturnAsync() => new(1);

// -->

public static int Return() { return new(1); }

After (PR)

public static ValueTask<int> ReturnAsync() => new(1);

// -->

public static int Return() { return 1; }

Copy link

codecov bot commented Jan 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f27382a) 94.23% compared to head (4607909) 94.26%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #49      +/-   ##
==========================================
+ Coverage   94.23%   94.26%   +0.02%     
==========================================
  Files           8        8              
  Lines         902      924      +22     
  Branches      192      198       +6     
==========================================
+ Hits          850      871      +21     
  Misses         24       24              
- Partials       28       29       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@virzak virzak merged commit 2114be3 into zompinc:master Jan 26, 2024
5 checks passed
@virzak
Copy link
Contributor

virzak commented Jan 26, 2024

Thanks so much. Easy to read and understand. Version 1.3.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants