Azure-docs: typo in sample new ModuleClient.CreateFromEnvironmentAsync

Created on 1 Aug 2019  Â·  8Comments  Â·  Source: MicrosoftDocs/azure-docs

it states ModuleClient client = new ModuleClient.CreateFromEnvironmentAsync(
but should probably be ModuleClient client = ModuleClient.CreateFromEnvironmentAsync(


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri2 doc-bug in-progress iot-edgsvc triaged

All 8 comments

Hi @xtofs Thanks for the feedback! Would you please provide more detail about why it should be changed? Is it a static class?

for one, it is a static (factory) method on ModuleClient
https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.devices.client.moduleclient.createfromenvironmentasync?view=azure-dotnet.
secondly, you have to deal with the fact that it is async.

Thanks you for the clarification @xtofs

As an async method that returns a Task<>, it should have 'await' in front of the declaration instead of 'new' or nothing. Do you agree, @xtofs and @Alberto-Vega-MSFT?

Yes,

  • since it is not a constructor, the new must be removed to compile.
  • to actually await and unwrap the task, it should use the await keyword (there are other ways but that would be off topic).

From: Kelly Gremban notifications@github.com
Sent: Friday, August 2, 2019 10:08 AM
To: MicrosoftDocs/azure-docs azure-docs@noreply.github.com
Cc: Christof Sprenger christof_sprenger@hotmail.com; Mention mention@noreply.github.com
Subject: Re: [MicrosoftDocs/azure-docs] typo in sample new ModuleClient.CreateFromEnvironmentAsync (#36264)

As an async method that returns a Task<>, it should have 'await' in front of the declaration instead of 'new' or nothing. Do you agree, @xtofshttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fxtofs&data=02%7C01%7C%7C16e5cce9dc114e05240208d7176c0c9b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637003625135965401&sdata=foDPEP6fSIUJqCZLc7Nl9bXkQXFbIxfd6pFIZ3xWKWI%3D&reserved=0 and @Alberto-Vega-MSFThttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAlberto-Vega-MSFT&data=02%7C01%7C%7C16e5cce9dc114e05240208d7176c0c9b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637003625135975405&sdata=YxEhPj%2Bxd7etqCds2sYcjVpSTsEKzuT4bXvru9XqJv4%3D&reserved=0?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMicrosoftDocs%2Fazure-docs%2Fissues%2F36264%3Femail_source%3Dnotifications%26email_token%3DACQRNRZGTUHSALXS5YHPNLDQCRSZBA5CNFSM4IILPW3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3OKNMI%23issuecomment-517777073&data=02%7C01%7C%7C16e5cce9dc114e05240208d7176c0c9b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637003625135985416&sdata=Bc76gYiogZbYc4qjrfSOZCCm77YFHhkOTI1zthHUjZU%3D&reserved=0, or mute the threadhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FACQRNR5UDYZTDOLNYKWBBU3QCRSZBANCNFSM4IILPW3A&data=02%7C01%7C%7C16e5cce9dc114e05240208d7176c0c9b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637003625135995420&sdata=7ctmEyB85%2BVRlwrIHz7VOPjVCzP028ieeiQh0pRYaUU%3D&reserved=0.

Thanks @kgremban added the await keyword

Yes

  • since it is not a constructor the ‚new‘ must be removed to compile
  • to actually await the task and unwrap it it should use the ‚await‘ (there are other ways but that would distract)

On Aug 2, 2019, at 10:08, Kelly Gremban <[email protected]notifications@github.com> wrote:

As an async method that returns a Task<>, it should have 'await' in front of the declaration instead of 'new' or nothing. Do you agree, @xtofshttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fxtofs&data=02%7C01%7C%7C16e5cce9dc114e05240208d7176c0c9b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637003625135965401&sdata=foDPEP6fSIUJqCZLc7Nl9bXkQXFbIxfd6pFIZ3xWKWI%3D&reserved=0 and @Alberto-Vega-MSFThttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAlberto-Vega-MSFT&data=02%7C01%7C%7C16e5cce9dc114e05240208d7176c0c9b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637003625135975405&sdata=YxEhPj%2Bxd7etqCds2sYcjVpSTsEKzuT4bXvru9XqJv4%3D&reserved=0?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMicrosoftDocs%2Fazure-docs%2Fissues%2F36264%3Femail_source%3Dnotifications%26email_token%3DACQRNRZGTUHSALXS5YHPNLDQCRSZBA5CNFSM4IILPW3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3OKNMI%23issuecomment-517777073&data=02%7C01%7C%7C16e5cce9dc114e05240208d7176c0c9b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637003625135985416&sdata=Bc76gYiogZbYc4qjrfSOZCCm77YFHhkOTI1zthHUjZU%3D&reserved=0, or mute the threadhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FACQRNR5UDYZTDOLNYKWBBU3QCRSZBANCNFSM4IILPW3A&data=02%7C01%7C%7C16e5cce9dc114e05240208d7176c0c9b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637003625135995420&sdata=7ctmEyB85%2BVRlwrIHz7VOPjVCzP028ieeiQh0pRYaUU%3D&reserved=0.

@xtofs Thanks for helping us make this docs better! Closing this issue now since the PR has been approved and merged.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JeffLoo-ong picture JeffLoo-ong  Â·  3Comments

Ponant picture Ponant  Â·  3Comments

AronT-TLV picture AronT-TLV  Â·  3Comments

bdcoder2 picture bdcoder2  Â·  3Comments

Agazoth picture Agazoth  Â·  3Comments