How do I get a warning in Visual Studio when async methods don't end in 'Async'?
How can I get Visual Studio to give me a naming warning each time I create an asynchronous method that doesn't end "Async"?
It's the recommended convention for asynchronous methods, but I often find myself forgetting to add that suffix and a warning would be useful.
c# visual-studio asynchronous
add a comment |
How can I get Visual Studio to give me a naming warning each time I create an asynchronous method that doesn't end "Async"?
It's the recommended convention for asynchronous methods, but I often find myself forgetting to add that suffix and a warning would be useful.
c# visual-studio asynchronous
3
Asynchronous code is now so ubiquitous that I don't see it as a practice anymore, unless you really have both versions.
– Adrian Iftode
8 hours ago
By "doesn't end Async", do you mean, the name of the method doesn't end in Async?
– Lasse Vågsæther Karlsen
8 hours ago
"It's the recommended convention for async methods" is it? It's kind of assumed, now.
– Alexander
5 hours ago
What we can do using Visual Studio Text Editor configurations or.editorconfig
file, is limited to warn about methods withasync
modifier, we cannot apply the rule for methods which returnTask
.
– Reza Aghaei
5 hours ago
add a comment |
How can I get Visual Studio to give me a naming warning each time I create an asynchronous method that doesn't end "Async"?
It's the recommended convention for asynchronous methods, but I often find myself forgetting to add that suffix and a warning would be useful.
c# visual-studio asynchronous
How can I get Visual Studio to give me a naming warning each time I create an asynchronous method that doesn't end "Async"?
It's the recommended convention for asynchronous methods, but I often find myself forgetting to add that suffix and a warning would be useful.
c# visual-studio asynchronous
c# visual-studio asynchronous
edited 4 hours ago
Peter Mortensen
13.5k1983111
13.5k1983111
asked 9 hours ago
Jez
11.5k1879151
11.5k1879151
3
Asynchronous code is now so ubiquitous that I don't see it as a practice anymore, unless you really have both versions.
– Adrian Iftode
8 hours ago
By "doesn't end Async", do you mean, the name of the method doesn't end in Async?
– Lasse Vågsæther Karlsen
8 hours ago
"It's the recommended convention for async methods" is it? It's kind of assumed, now.
– Alexander
5 hours ago
What we can do using Visual Studio Text Editor configurations or.editorconfig
file, is limited to warn about methods withasync
modifier, we cannot apply the rule for methods which returnTask
.
– Reza Aghaei
5 hours ago
add a comment |
3
Asynchronous code is now so ubiquitous that I don't see it as a practice anymore, unless you really have both versions.
– Adrian Iftode
8 hours ago
By "doesn't end Async", do you mean, the name of the method doesn't end in Async?
– Lasse Vågsæther Karlsen
8 hours ago
"It's the recommended convention for async methods" is it? It's kind of assumed, now.
– Alexander
5 hours ago
What we can do using Visual Studio Text Editor configurations or.editorconfig
file, is limited to warn about methods withasync
modifier, we cannot apply the rule for methods which returnTask
.
– Reza Aghaei
5 hours ago
3
3
Asynchronous code is now so ubiquitous that I don't see it as a practice anymore, unless you really have both versions.
– Adrian Iftode
8 hours ago
Asynchronous code is now so ubiquitous that I don't see it as a practice anymore, unless you really have both versions.
– Adrian Iftode
8 hours ago
By "doesn't end Async", do you mean, the name of the method doesn't end in Async?
– Lasse Vågsæther Karlsen
8 hours ago
By "doesn't end Async", do you mean, the name of the method doesn't end in Async?
– Lasse Vågsæther Karlsen
8 hours ago
"It's the recommended convention for async methods" is it? It's kind of assumed, now.
– Alexander
5 hours ago
"It's the recommended convention for async methods" is it? It's kind of assumed, now.
– Alexander
5 hours ago
What we can do using Visual Studio Text Editor configurations or
.editorconfig
file, is limited to warn about methods with async
modifier, we cannot apply the rule for methods which return Task
.– Reza Aghaei
5 hours ago
What we can do using Visual Studio Text Editor configurations or
.editorconfig
file, is limited to warn about methods with async
modifier, we cannot apply the rule for methods which return Task
.– Reza Aghaei
5 hours ago
add a comment |
2 Answers
2
active
oldest
votes
From Options,
- Go to Text Editor → Basic → Code Style → Naming
- Select Manage Specifications and Add New Specification
- Select Method, tick all accessibility options and from Modifiers, select Async.
- Give the title as Async Method and save
- Now get into Manage Naming Styles and add New Style. Add Async as suffix and give it a name as AsyncSuffix, and then save
- Now press the plus sign and create new naming. Select specification as Async Method, select required Style as AsyncPostfix and Severity as Suggestor.
- Click OK and save
add a comment |
In addition to Visual Studio Text Editor Settings, you can create portable, custom editor settings .editorconfig
file. Visual Studio 2017 natively supports .editorconfig
files.
By creating the .editorconfig
file as part of the solution, and pushing it to the repository, you can enforce consistent coding styles for everyone that works in that codebase, regardless of their Visual Studio Text Editor Settings.
EditorConfig settings take precedence over global Visual Studio text
editor settings.
To do so:
- In the Solution Explorer, select the Solution, Project or a folder in project, depending to the scope which you want to apply the naming rule.
- Right click and select Add New Item or Press Ctrl + Shift + A
- Choose Text File file from General categories and enter
.editorconfig
as file name.
Paste the following content in the file:
[*.{cs,vb}]
# Async methods should have "Async" suffix
dotnet_naming_rule.async_methods_end_in_async.symbols = any_async_methods
dotnet_naming_rule.async_methods_end_in_async.style = end_in_async
dotnet_naming_rule.async_methods_end_in_async.severity = suggestion
dotnet_naming_symbols.any_async_methods.applicable_kinds = method
dotnet_naming_symbols.any_async_methods.applicable_accessibilities = *
dotnet_naming_symbols.any_async_methods.required_modifiers = async
dotnet_naming_style.end_in_async.required_prefix =
dotnet_naming_style.end_in_async.required_suffix = Async
dotnet_naming_style.end_in_async.capitalization = pascal_case
dotnet_naming_style.end_in_async.word_separator =
More Information:
- Create portable, custom editor settings with EditorConfig
- EditorConfig
Example
– Reza Aghaei
8 hours ago
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53972941%2fhow-do-i-get-a-warning-in-visual-studio-when-async-methods-dont-end-in-async%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
From Options,
- Go to Text Editor → Basic → Code Style → Naming
- Select Manage Specifications and Add New Specification
- Select Method, tick all accessibility options and from Modifiers, select Async.
- Give the title as Async Method and save
- Now get into Manage Naming Styles and add New Style. Add Async as suffix and give it a name as AsyncSuffix, and then save
- Now press the plus sign and create new naming. Select specification as Async Method, select required Style as AsyncPostfix and Severity as Suggestor.
- Click OK and save
add a comment |
From Options,
- Go to Text Editor → Basic → Code Style → Naming
- Select Manage Specifications and Add New Specification
- Select Method, tick all accessibility options and from Modifiers, select Async.
- Give the title as Async Method and save
- Now get into Manage Naming Styles and add New Style. Add Async as suffix and give it a name as AsyncSuffix, and then save
- Now press the plus sign and create new naming. Select specification as Async Method, select required Style as AsyncPostfix and Severity as Suggestor.
- Click OK and save
add a comment |
From Options,
- Go to Text Editor → Basic → Code Style → Naming
- Select Manage Specifications and Add New Specification
- Select Method, tick all accessibility options and from Modifiers, select Async.
- Give the title as Async Method and save
- Now get into Manage Naming Styles and add New Style. Add Async as suffix and give it a name as AsyncSuffix, and then save
- Now press the plus sign and create new naming. Select specification as Async Method, select required Style as AsyncPostfix and Severity as Suggestor.
- Click OK and save
From Options,
- Go to Text Editor → Basic → Code Style → Naming
- Select Manage Specifications and Add New Specification
- Select Method, tick all accessibility options and from Modifiers, select Async.
- Give the title as Async Method and save
- Now get into Manage Naming Styles and add New Style. Add Async as suffix and give it a name as AsyncSuffix, and then save
- Now press the plus sign and create new naming. Select specification as Async Method, select required Style as AsyncPostfix and Severity as Suggestor.
- Click OK and save
edited 4 hours ago
Peter Mortensen
13.5k1983111
13.5k1983111
answered 8 hours ago
Simonare
4,73611134
4,73611134
add a comment |
add a comment |
In addition to Visual Studio Text Editor Settings, you can create portable, custom editor settings .editorconfig
file. Visual Studio 2017 natively supports .editorconfig
files.
By creating the .editorconfig
file as part of the solution, and pushing it to the repository, you can enforce consistent coding styles for everyone that works in that codebase, regardless of their Visual Studio Text Editor Settings.
EditorConfig settings take precedence over global Visual Studio text
editor settings.
To do so:
- In the Solution Explorer, select the Solution, Project or a folder in project, depending to the scope which you want to apply the naming rule.
- Right click and select Add New Item or Press Ctrl + Shift + A
- Choose Text File file from General categories and enter
.editorconfig
as file name.
Paste the following content in the file:
[*.{cs,vb}]
# Async methods should have "Async" suffix
dotnet_naming_rule.async_methods_end_in_async.symbols = any_async_methods
dotnet_naming_rule.async_methods_end_in_async.style = end_in_async
dotnet_naming_rule.async_methods_end_in_async.severity = suggestion
dotnet_naming_symbols.any_async_methods.applicable_kinds = method
dotnet_naming_symbols.any_async_methods.applicable_accessibilities = *
dotnet_naming_symbols.any_async_methods.required_modifiers = async
dotnet_naming_style.end_in_async.required_prefix =
dotnet_naming_style.end_in_async.required_suffix = Async
dotnet_naming_style.end_in_async.capitalization = pascal_case
dotnet_naming_style.end_in_async.word_separator =
More Information:
- Create portable, custom editor settings with EditorConfig
- EditorConfig
Example
– Reza Aghaei
8 hours ago
add a comment |
In addition to Visual Studio Text Editor Settings, you can create portable, custom editor settings .editorconfig
file. Visual Studio 2017 natively supports .editorconfig
files.
By creating the .editorconfig
file as part of the solution, and pushing it to the repository, you can enforce consistent coding styles for everyone that works in that codebase, regardless of their Visual Studio Text Editor Settings.
EditorConfig settings take precedence over global Visual Studio text
editor settings.
To do so:
- In the Solution Explorer, select the Solution, Project or a folder in project, depending to the scope which you want to apply the naming rule.
- Right click and select Add New Item or Press Ctrl + Shift + A
- Choose Text File file from General categories and enter
.editorconfig
as file name.
Paste the following content in the file:
[*.{cs,vb}]
# Async methods should have "Async" suffix
dotnet_naming_rule.async_methods_end_in_async.symbols = any_async_methods
dotnet_naming_rule.async_methods_end_in_async.style = end_in_async
dotnet_naming_rule.async_methods_end_in_async.severity = suggestion
dotnet_naming_symbols.any_async_methods.applicable_kinds = method
dotnet_naming_symbols.any_async_methods.applicable_accessibilities = *
dotnet_naming_symbols.any_async_methods.required_modifiers = async
dotnet_naming_style.end_in_async.required_prefix =
dotnet_naming_style.end_in_async.required_suffix = Async
dotnet_naming_style.end_in_async.capitalization = pascal_case
dotnet_naming_style.end_in_async.word_separator =
More Information:
- Create portable, custom editor settings with EditorConfig
- EditorConfig
Example
– Reza Aghaei
8 hours ago
add a comment |
In addition to Visual Studio Text Editor Settings, you can create portable, custom editor settings .editorconfig
file. Visual Studio 2017 natively supports .editorconfig
files.
By creating the .editorconfig
file as part of the solution, and pushing it to the repository, you can enforce consistent coding styles for everyone that works in that codebase, regardless of their Visual Studio Text Editor Settings.
EditorConfig settings take precedence over global Visual Studio text
editor settings.
To do so:
- In the Solution Explorer, select the Solution, Project or a folder in project, depending to the scope which you want to apply the naming rule.
- Right click and select Add New Item or Press Ctrl + Shift + A
- Choose Text File file from General categories and enter
.editorconfig
as file name.
Paste the following content in the file:
[*.{cs,vb}]
# Async methods should have "Async" suffix
dotnet_naming_rule.async_methods_end_in_async.symbols = any_async_methods
dotnet_naming_rule.async_methods_end_in_async.style = end_in_async
dotnet_naming_rule.async_methods_end_in_async.severity = suggestion
dotnet_naming_symbols.any_async_methods.applicable_kinds = method
dotnet_naming_symbols.any_async_methods.applicable_accessibilities = *
dotnet_naming_symbols.any_async_methods.required_modifiers = async
dotnet_naming_style.end_in_async.required_prefix =
dotnet_naming_style.end_in_async.required_suffix = Async
dotnet_naming_style.end_in_async.capitalization = pascal_case
dotnet_naming_style.end_in_async.word_separator =
More Information:
- Create portable, custom editor settings with EditorConfig
- EditorConfig
In addition to Visual Studio Text Editor Settings, you can create portable, custom editor settings .editorconfig
file. Visual Studio 2017 natively supports .editorconfig
files.
By creating the .editorconfig
file as part of the solution, and pushing it to the repository, you can enforce consistent coding styles for everyone that works in that codebase, regardless of their Visual Studio Text Editor Settings.
EditorConfig settings take precedence over global Visual Studio text
editor settings.
To do so:
- In the Solution Explorer, select the Solution, Project or a folder in project, depending to the scope which you want to apply the naming rule.
- Right click and select Add New Item or Press Ctrl + Shift + A
- Choose Text File file from General categories and enter
.editorconfig
as file name.
Paste the following content in the file:
[*.{cs,vb}]
# Async methods should have "Async" suffix
dotnet_naming_rule.async_methods_end_in_async.symbols = any_async_methods
dotnet_naming_rule.async_methods_end_in_async.style = end_in_async
dotnet_naming_rule.async_methods_end_in_async.severity = suggestion
dotnet_naming_symbols.any_async_methods.applicable_kinds = method
dotnet_naming_symbols.any_async_methods.applicable_accessibilities = *
dotnet_naming_symbols.any_async_methods.required_modifiers = async
dotnet_naming_style.end_in_async.required_prefix =
dotnet_naming_style.end_in_async.required_suffix = Async
dotnet_naming_style.end_in_async.capitalization = pascal_case
dotnet_naming_style.end_in_async.word_separator =
More Information:
- Create portable, custom editor settings with EditorConfig
- EditorConfig
edited 4 hours ago
answered 8 hours ago
Reza Aghaei
64k851150
64k851150
Example
– Reza Aghaei
8 hours ago
add a comment |
Example
– Reza Aghaei
8 hours ago
Example
– Reza Aghaei
8 hours ago
Example
– Reza Aghaei
8 hours ago
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53972941%2fhow-do-i-get-a-warning-in-visual-studio-when-async-methods-dont-end-in-async%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
Asynchronous code is now so ubiquitous that I don't see it as a practice anymore, unless you really have both versions.
– Adrian Iftode
8 hours ago
By "doesn't end Async", do you mean, the name of the method doesn't end in Async?
– Lasse Vågsæther Karlsen
8 hours ago
"It's the recommended convention for async methods" is it? It's kind of assumed, now.
– Alexander
5 hours ago
What we can do using Visual Studio Text Editor configurations or
.editorconfig
file, is limited to warn about methods withasync
modifier, we cannot apply the rule for methods which returnTask
.– Reza Aghaei
5 hours ago