Hidden Disposables
I didn't know there's something like this. And I found it here:
This is a refresh of the implementations discussed.
The implementations is still valid but aged (so will this one), and I gave it a refresh.
InsightsInstrumentationKey iKey = "12345"; | |
PrintResult(iKey); | |
iKey = "6e12e0b1-0cbd-4fe9-9b5d-2d8a46e672fe"; | |
PrintResult(iKey); | |
iKey = Guid.NewGuid(); | |
PrintResult(iKey); | |
void PrintResult(InsightsInstrumentationKey iKey) |
async void AsyncJob() | |
{ | |
await Task.Delay(100); | |
throw new InvalidOperationException("Hello exception!"); | |
// Console.WriteLine("Job is done!"); | |
} | |
try | |
{ | |
// Notice: the exception thrown by AsyncJob won't be |
using Android.Content; | |
using Android.OS; | |
using Android.Security; | |
using Android.Security.Keystore; | |
using Java.Math; | |
using Java.Security; | |
using Javax.Security.Auth.X500; | |
using Calendar = Android.Icu.Util.Calendar; | |
using CalendarField = Android.Icu.Util.CalendarField; |
The Azure Storage SDK doens't provide an overload to have both parameters for overwrting and a BlobUploadOptions
. But that is a common scenario.
By reading the implementations, it looks like it is easy to do:
using (Stream contentStream = File.OpenRead(@"C:\tmp\Test.txt"))
{
BlobUploadOptions overwriteWithTags = new BlobUploadOptions
{
This is a cheetsheet to copy files to output directory in a MSBuild project file.
For example, this will copy settings.json to output directory when the one in current folder is newer.
<Project Sdk="Microsoft.NET.Sdk">
...
<ItemGroup>
<!-- Build action is `None`, and the option for copy to output directory could be `Always` or `PreserveNewest` -->
<None Include="./settings.json" CopyToOutputDirectory="PreserveNewest" />
This is a retrospective. I had an Azure Function, connected to a ServieBus Topic for message processing. It functions, messages triggered the function, function processed the message, all good, except it didn't scale no matter how many message was stacked up in the topic.
To debug it, I built a lab with mimimum components. To share some context, this is how the trigger attribute looks like on the function:
[Function("OnGetMessage")]
public void Run([ServiceBusTrigger("message", "message-sub", Connection = "LabServiceBus")] string mySbMsg)
This is a cheatsheet for generating underscore for readonly field by editorconfig:
[*.{cs,vb}]
dotnet_naming_rule.private_members_with_underscore.symbols = private_fields
dotnet_naming_rule.private_members_with_underscore.style = prefix_underscore
dotnet_naming_rule.private_members_with_underscore.severity = suggestion
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private