Should I await a single line "pass through" method?

1 day ago 3
ARTICLE AD BOX

Consider the following call chain:

public class MainClass { // Lets say this is called from a front-end button click. public async SomeButtonClick() { await OtherClass.SomeMethodAsync(); } } public static class OtherClass { public static async Task<bool> SomeMethodAsync() { return await OtherHiddenClass.SomeHiddenMethodAsync(); } } static class OtherHiddenClass { public static async Task<bool> SomeHiddenMethodAsync() { // some code in here doing things. } }

In the above (contrived) example, could SomeMethodAsync() actually simply be defined as:

public static Task<bool> SomeMethodAsync() { return OtherHiddenClass.SomeHiddenMethodAsync(); } or rather public static Task<bool> SomeMethodAsync() => OtherHiddenClass.SomeHiddenMethodAsync();

...since it's just "passing on" the call to the real async method and returning the Task for the caller of this to await ?

The real-life code is using a lot of implementations of interfaces with some doing these single line calls.

Read Entire Article