-
Notifications
You must be signed in to change notification settings - Fork 197
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
Remove redundant project config, add file-scoped namespaces #1611
base: dev
Are you sure you want to change the base?
Conversation
760e2cd
to
1a87801
Compare
<ItemGroup> | ||
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext"/> | ||
</ItemGroup> | ||
<!--#endif --> | ||
<!--#if (NetFramework)--> | ||
<ItemGroup> | ||
<Folder Include="Properties\" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can also be removed.
namespace Company.Function | ||
namespace Company.Function; | ||
|
||
public class BlobTriggerCSharp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also use primary constructors.
public class BlobTriggerCSharp | |
public class BlobTriggerCSharp(ILogger<BlobTriggerCSharp> logger) |
Then don't even have the _logger
field. You can access the ctor parameter anywhere in this class via logger
.
{ | ||
_logger = loggerFactory.CreateLogger<CosmosDBTriggerCSharp>(); | ||
} | ||
public CosmosDBTriggerCSharp(ILoggerFactory loggerFactory) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommend primary constructor and also switching to ILogger<CosmosDBTriggerCSharp>
{ | ||
using var blobStreamReader = new StreamReader(stream); | ||
var content = await blobStreamReader.ReadToEndAsync(); | ||
_logger.LogInformation($"C# Blob Trigger (using Event Grid) processed blob\n Name: {name} \n Data: {content}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably not encourage bad logging practices in our samples (but not sure if that is in the scope of this PR)
Cleaning up templates by removing some verbosity. Some of the settings in the project template have been unnecessary since the SDK provides many of these behaviors already. Of note, we're also removing the reference to
Microsoft.Azure.Functions.Worker.Extensions.Http
whenMicrosoft.Azure.Functions.Worker.Extensions.Http.AspNetCore
is included, since it's already pulling it in transitively. For the item templates, we're just moving to file-scoped namespaces (which involves removing indentation and is making the diff messy), as that gets rid of a small bit of clutter.