<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.1.1">Jekyll</generator><link href="https://jweiler.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://jweiler.com/" rel="alternate" type="text/html" /><updated>2024-05-11T11:04:14+00:00</updated><id>https://jweiler.com/feed.xml</id><title type="html">Coding Adventures</title><subtitle>I'm a software developer in southeastern Pennsylvania who loves learning new things.</subtitle><entry><title type="html">Thoughts on software development</title><link href="https://jweiler.com/software/2024/05/10/thoughts-on-software-development.html" rel="alternate" type="text/html" title="Thoughts on software development" /><published>2024-05-10T10:04:29+00:00</published><updated>2024-05-10T10:04:29+00:00</updated><id>https://jweiler.com/software/2024/05/10/thoughts-on-software-development</id><content type="html" xml:base="https://jweiler.com/software/2024/05/10/thoughts-on-software-development.html">&lt;p&gt;I thought I’d put together some of my thoughts on the future of software development. Things like AI, outsourcing and other trends have gotten some people concerned about the future of software development (and white collar work in general) especially in Unites States.&lt;/p&gt;

&lt;p&gt;I came up with a few categories of things affecting software development some recently and others not so recent.&lt;/p&gt;

&lt;h3 id=&quot;tax-changes-section-174&quot;&gt;Tax Changes (Section 174)&lt;/h3&gt;
&lt;p&gt;When the Tax Cuts and Jobs Act was passed in 2018 there was a provision that took effect in 2022. This was that Software Development was to be categorized as research and experimentation expenditures and not able to fully expensed.&lt;/p&gt;

&lt;p&gt;From &lt;a href=&quot;https://www.eisneramper.com/insights/tax/impact-174-software-1023/&quot;&gt;eisneramper.com&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;Under the amended code section, businesses are now required to charge the R&amp;amp;E expenditures to a capital asset and amortize the asset over a 5-year period (15 years in the case of foreign R&amp;amp;E expenditures). These expenditures must also be amortized using the mid-year convention, meaning that in the first year, taxpayers will only be allowed to deduct 10% of the total R&amp;amp;E expenditures.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Needless to say, this has been catching software business owners off guard with much higher than expected tax bills.&lt;/p&gt;

&lt;p&gt;Eventually the full expense will be able to be taken but still it seems absolutely insane that a business owner cannot fully expense a software developers’ salary in one year.&lt;/p&gt;

&lt;h3 id=&quot;ai&quot;&gt;AI&lt;/h3&gt;
&lt;p&gt;Ever since ChatGPT came out in 2022 AI has been a topic of interest in the software development industry. Doing searches for the future of software development will give you a wide range of ideas and opinions on what it means for the future. There seems to be a fear among some that now software will almost write itself therefore drastically reducing the amount of developers needed.&lt;/p&gt;

&lt;p&gt;I don’t know that I really subscribe to that idea. Personally, I love using GitHub Copilot, ChatGPT, Microsoft Copilot and other AI tools to help me write software. It helps tremendously with boring boilerplate code and lets you get to the more interesting things. It also can be helpful and suggesting code but you do need to know what you are doing and not blindly accept whatever it suggests.&lt;/p&gt;

&lt;p&gt;I feel that developers that do not use AI tools may be replaced by those who do. I believe it’s a great tool to have in your toolbox making you more productive than before.&lt;/p&gt;

&lt;p&gt;It is quite possible that some executives will see AI as being able to reduce the people needed and proceed to lay off people in hopes to accomplish the same with less (and possibly this has already happened). However, I feel that the better way to think about this is with the same amount of people an organization will now be able to accomplish even more than before.&lt;/p&gt;

&lt;h3 id=&quot;outsourcing-work&quot;&gt;Outsourcing work&lt;/h3&gt;

&lt;p&gt;Outsourcing is not a new thing; it has been done for decades by many companies. However, there does seem to be a trend with an influx of new companies starting around finding employees for small companies. The idea of finding employees to do white collar work at up to an 80% reduction in cost seems to be an easy sell for many businesses.&lt;/p&gt;

&lt;p&gt;This can work and has worked for many people. However, talk to people that have tried outsourcing and there are plenty of stories of things that have gone wrong.&lt;/p&gt;

&lt;p&gt;I do believe there could be some benefit in a US based business supplementing their local workforce with some employees abroad and more than just cost savings. Say you want to have support available 24/7, having people spread out across the globe could really help with this.&lt;/p&gt;

&lt;h3 id=&quot;what-to-think-of-it-all&quot;&gt;What to think of it all?&lt;/h3&gt;

&lt;p&gt;If you have a small startup with mostly software developers and it was making a small profit before the recent tax changes, they may be forced to reduce headcount in United States to stay in business. For them instead hiring a few employees in Philippines may be appealing to them.&lt;/p&gt;

&lt;p&gt;For a more established business with more diverse forms of income the recent tax changes may not be as painful.&lt;/p&gt;

&lt;p&gt;In addition to the things I mentioned we still could be dealing with the effects of the massive hiring surge that happened in 2020-2021. The recent tech layoffs I believe are in part shedding people that probably were not needed in the first place. Also, there is economic uncertainty with some fearing a recession is just around the corner.&lt;/p&gt;

&lt;p&gt;All of these things together are more than my finite mind can really comprehend on what might happen in the future.&lt;/p&gt;

&lt;p&gt;Out of these things I would think outsourcing may have the biggest impact on software developers in the Unites States. However, I don’t think it’s a doomsday scenario where we should all go looking for other jobs fearing that we may have our salaries cut in half. I think there probably is benefit for many companies to supplement their team with a few people abroad keeping a core team in US.&lt;/p&gt;

&lt;p&gt;Also, I didn’t mention how more and more things rely on software in our world and I see that only continuing pushing the need for more developers.&lt;/p&gt;

&lt;p&gt;I think for an experienced developer the future is still fairly bright and their skills will be in demand for quite some time yet even here in the US. Now on the other hand in 10 years when my son is looking to start a job I don’t know if I will still agree on it being a good career or not. I guess I’ll have to wait and see!&lt;/p&gt;

&lt;p&gt;Also if you are a developer in a country where labor is inexpensive compared to United States, I think things will be very good for you! If outsourcing continues to grow there should be strong upward pressure on salaries in those areas.&lt;/p&gt;

&lt;p&gt;What do you think? Agree or disagree? I’d love to hear your thoughs either way. Reach out to me on &lt;a href=&quot;https://twitter.com/jsweiler&quot;&gt;Twitter (X)&lt;/a&gt; anytime.&lt;/p&gt;</content><author><name></name></author><category term="software" /><summary type="html">I thought I’d put together some of my thoughts on the future of software development. Things like AI, outsourcing and other trends have gotten some people concerned about the future of software development (and white collar work in general) especially in Unites States.</summary></entry><entry><title type="html">c# required keyword</title><link href="https://jweiler.com/csharp/2023/03/10/csharp-required-keyword.html" rel="alternate" type="text/html" title="c# required keyword" /><published>2023-03-10T10:04:29+00:00</published><updated>2023-03-10T10:04:29+00:00</updated><id>https://jweiler.com/csharp/2023/03/10/csharp-required-keyword</id><content type="html" xml:base="https://jweiler.com/csharp/2023/03/10/csharp-required-keyword.html">&lt;p&gt;The required keyword is a new feature in C# 11 and it can be very helpful to make sure your objects are used as they are intended to be. The name is fairly self explanatory, the required keyword allows you to specify that fields and properties must be passed in via an object initializer.&lt;/p&gt;

&lt;p&gt;This keyword applies to classes, structs, records, and record structs.&lt;/p&gt;

&lt;p&gt;You use it like this:&lt;/p&gt;

&lt;div class=&quot;language-csharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Person&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;required&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Name&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;required&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Age&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;If you try to create a Person object without passing in any values, you will get a compiler error. You cannot do this: var person = new Person(). You need to specify the required values:&lt;/p&gt;

&lt;div class=&quot;language-csharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;person&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Person&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Name&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Bob&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Age&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;5&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;I made both of my properties required, but I could have some that are and some that aren’t.&lt;/p&gt;

&lt;p&gt;This is much better than the previous way of making a class that had properties that were needed. Before you needed to specify a constructor and pass them in. It required more code to do the same thing:&lt;/p&gt;

&lt;div class=&quot;language-csharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Person&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Name&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Age&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;Name&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;Age&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;I will note that you can use the SetsRequiredMembers attribute on a class and that will tell the compiler that the constructor initializes all required members, but it doesn’t actually verify anything. However, I would use caution before using this.&lt;/p&gt;

&lt;p&gt;I think this is a very nice feature and am excited to use it more often. It will be something else for new programmers to learn, but in this case I believe the name is very clear and descriptive of what the keyword is actually used for.&lt;/p&gt;</content><author><name></name></author><category term="csharp" /><summary type="html">The required keyword is a new feature in C# 11 and it can be very helpful to make sure your objects are used as they are intended to be. The name is fairly self explanatory, the required keyword allows you to specify that fields and properties must be passed in via an object initializer.</summary></entry><entry><title type="html">c# overview of records</title><link href="https://jweiler.com/csharp/2023/03/06/overview-of-records-csharp.html" rel="alternate" type="text/html" title="c# overview of records" /><published>2023-03-06T10:04:29+00:00</published><updated>2023-03-06T10:04:29+00:00</updated><id>https://jweiler.com/csharp/2023/03/06/overview-of-records-csharp</id><content type="html" xml:base="https://jweiler.com/csharp/2023/03/06/overview-of-records-csharp.html">&lt;p&gt;So if you are familiar with C# have interacted with many classes and most likely created many of your own classes.&lt;/p&gt;

&lt;p&gt;A class is an object which can have things like properties and methods and much more on them.&lt;/p&gt;

&lt;p&gt;Records were introduced in C# 9 as a keyword to define a &lt;a href=&quot;https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/reference-types&quot;&gt;reference type&lt;/a&gt; that provides built-in functionality for encapsulating data.&lt;/p&gt;

&lt;p&gt;You can create a record in these two ways:&lt;/p&gt;

&lt;div class=&quot;language-csharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;record&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Person&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;FirstName&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;LastName&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Age&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;record&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;FirstName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;LastName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You will notice the first way looks very similar to a class with a few differences. One of them is the init keyword instead of a set. This was also introduced in C# 9 and this is what the Microsoft docs say:&lt;/p&gt;

&lt;p&gt;An init-only setter assigns a value to the property or the indexer element only during object construction. This enforces immutability, so that once the object is initialized, it can’t be changed again.&lt;/p&gt;

&lt;p&gt;So if you try to set a property after creating the object like this you will get a compiler error:&lt;/p&gt;

&lt;div class=&quot;language-csharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;person&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;FirstName&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Bob&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You only can set the properties from the object initializer like this&lt;/p&gt;

&lt;div class=&quot;language-csharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;person&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Person&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;FirstName&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Bob&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;LastName&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Jones&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Age&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;30&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;In C#11 the required keyword was introduced and I show how you can apply that to a record. The required keyword when used on a property requires that you provide a value for it when you create the object. So we can change our record to look like this:&lt;/p&gt;

&lt;div class=&quot;language-csharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;record&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Person&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;required&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;FirstName&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;required&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;LastName&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;required&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Age&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;That forces us to pass in values in the object initializer or else we get a compiler error.&lt;/p&gt;

&lt;p&gt;The second way of creating records looks like this:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;public record Person(string FirstName, string LastName, int Age);&lt;/code&gt;
That is much simpler but what is it doing? Behind the scenes it creates a public auto-implemented property with an init setter for each parameter we have. These records are called positional records. We can create an instance of this record just like you would with a class:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;var person = new Person(&quot;Bob&quot;, &quot;Jones&quot;, 30);&lt;/code&gt;
In this way you are also forced to pass in all the parameters. Now if you wanted to use a positional record but also able to mutate one of the properties you could do something like this which would allow you to set Age later.&lt;/p&gt;

&lt;div class=&quot;language-csharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;record&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;FirstName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;LastName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Age&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;I personally like the short and easy syntax of the positional record. If you have an object that you want to be immutable, it’s a very easy way to accomplish that.&lt;/p&gt;

&lt;p&gt;One other thing to note about records is that unlike classes two records are equal to each other if they have all the same values and are of the same type. For example:&lt;/p&gt;

&lt;div class=&quot;language-csharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;person&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Bob&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Jones&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;person2&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Bob&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Jones&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;equal&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;person&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;person2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// equal is true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Also there is a way to copy a record while changing some of the data using the with keyword. So you could go like this:&lt;/p&gt;

&lt;div class=&quot;language-csharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;person&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Bob&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Jones&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;person2&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;person&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;FirstName&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Sally&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;That would give you a new record with the FirstName of Sally instead of Bob, the other properties would be the same. Also when doing this person == person2 would be false.&lt;/p&gt;

&lt;p&gt;There is a lot more to records that what I mentioned here. If you want to learn more be sure to check out the &lt;a href=&quot;https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/record&quot;&gt;Microsoft docs site&lt;/a&gt;.&lt;/p&gt;</content><author><name></name></author><category term="csharp" /><summary type="html">So if you are familiar with C# have interacted with many classes and most likely created many of your own classes.</summary></entry><entry><title type="html">c# switch syntax overview</title><link href="https://jweiler.com/csharp/2023/03/06/csharp-switch-syntax-overview.html" rel="alternate" type="text/html" title="c# switch syntax overview" /><published>2023-03-06T10:04:29+00:00</published><updated>2023-03-06T10:04:29+00:00</updated><id>https://jweiler.com/csharp/2023/03/06/csharp-switch-syntax-overview</id><content type="html" xml:base="https://jweiler.com/csharp/2023/03/06/csharp-switch-syntax-overview.html">&lt;p&gt;The C# switch statement can be a very handy way to avoid having many if/elseif statements. You probably have used the switch syntax many times in your C# code. Switch statements over the last few years have gotten some improvements which we will look at. You have probably seen code like this before:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-charp&quot;&gt;public string BuildText(int stars)
{
    switch (stars)
    {
        case 1:
        case 2:
            return &quot;This is a very poor rating.&quot;;
        case 3:
            return &quot;This is a mediocre rating.&quot;;
        case 4:
        case 5:
            return &quot;This is an acceptable rating.&quot;;
        default:
            return &quot;This is either a really good, or really bad rating.&quot;;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In C# 8 there was an update that would allow you to go like this instead.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-charp&quot;&gt;return stars switch
{
    1 =&amp;gt; &quot;This is a very poor rating.&quot;,
    2 =&amp;gt; &quot;This is a very poor rating.&quot;,
    3 =&amp;gt; &quot;This is a medicre rating.&quot;,
    4 =&amp;gt; &quot;This is an acceptable rating.&quot;,
    5 =&amp;gt; &quot;This is an acceptable rating.&quot;,
    _ =&amp;gt; &quot;This is either a really good, or really bad rating.&quot;
};
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is a statement that will return a string. That is clean but we can make it even better. We can get rid of the duplicate code by using the or syntax:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-charp&quot;&gt;return stars switch
{
    1 or 2 =&amp;gt; &quot;This is a very poor rating.&quot;,
    3 =&amp;gt; &quot;This is a medicre rating.&quot;,
    4 or 5 =&amp;gt; &quot;This is an acceptable rating.&quot;,
    _ =&amp;gt; &quot;This is either a really good, or really bad rating.&quot;
};
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In C# 9 they introduced pattern matching in switch statements. Let’s say you have a simple Person class like this.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-charp&quot;&gt;public class Person
{
    public string Name { get; set; }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You could easily write a switch statement to only match on a Person with a Name of John.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-charp&quot;&gt;var person = new Person { Name = &quot;John&quot; };
var text = person switch
{
    Person { Name: &quot;John&quot;} =&amp;gt; &quot;Hello John&quot;,
    _ =&amp;gt; &quot;I don't recognize you, sorry&quot;
};
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You could also write it like this, giving a variable name for the person and using a when clause to match on a specified condition.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-charp&quot;&gt;var text = person switch
{
    Person per when per.Name is &quot;John&quot; =&amp;gt; &quot;Hello John&quot;,
    _ =&amp;gt; &quot;I don't recognize you, sorry&quot;
};
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I like the first person switch example myself, but both ways do work. I should also note that when using the property pattern you can match on more that just John by doing this:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-charp&quot;&gt;var text = person switch
{
    Person { Name: &quot;John&quot; or &quot;Sally&quot;} =&amp;gt; &quot;Hello John or Sally&quot;,
    _ =&amp;gt; &quot;I don't recognize you, sorry&quot;
};
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You will have noticed I made use of the discard _ quite a bit. This is an alternative to the default option you would use in the more traditional C# syntax.&lt;/p&gt;

&lt;p&gt;As you can see switch statements have gotten more powerful over the years and also much more concise. I certainly like the shorter syntax and also the ability to do pattern matching as well.&lt;/p&gt;</content><author><name></name></author><category term="csharp" /><summary type="html">The C# switch statement can be a very handy way to avoid having many if/elseif statements. You probably have used the switch syntax many times in your C# code. Switch statements over the last few years have gotten some improvements which we will look at. You have probably seen code like this before:</summary></entry><entry><title type="html">c# quick tip - string fixed length</title><link href="https://jweiler.com/csharp/2023/03/03/csharp-tip-string-fixed-length.html" rel="alternate" type="text/html" title="c# quick tip - string fixed length" /><published>2023-03-03T10:04:29+00:00</published><updated>2023-03-03T10:04:29+00:00</updated><id>https://jweiler.com/csharp/2023/03/03/csharp-tip-string-fixed-length</id><content type="html" xml:base="https://jweiler.com/csharp/2023/03/03/csharp-tip-string-fixed-length.html">&lt;p&gt;I’m going to share a quick tip on how to easily create strings of a fixed length. For example suppose you have two strings like this.&lt;/p&gt;

&lt;div class=&quot;language-csharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;text1&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Short text&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;text2&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;This is a longer text&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;But you want to have this instead:&lt;/p&gt;

&lt;p&gt;“Short text…………….”
“This is a longer text…..”
So you want all strings to be 25 characters long and fill in with . if needed to get there.&lt;/p&gt;

&lt;p&gt;One way you could do this is like this:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;var newText2 = text2 + new string('.', 25 - text2.Length);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That would give you This is a longer text…. for text2 and Short text…………… for text1.&lt;/p&gt;

&lt;p&gt;Now the second parameter in the string constructor cannot be negative so you want to check that maybe like this &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;new string('.', (25 - text2.Length) &amp;lt; 0 ? 0 : 25 - text2.Length)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;However there is another way that is even easier. You can use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PadRight&lt;/code&gt; to accomplish the same thing. So &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;var newText2 = text2.PadRight(25, '.');&lt;/code&gt; will give you the same result This is a longer text….&lt;/p&gt;

&lt;p&gt;There is also a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PadLeft&lt;/code&gt; if you want to right align your text instead.&lt;/p&gt;

&lt;p&gt;Hopefully this quick tip may be of value to you sometime.&lt;/p&gt;</content><author><name></name></author><category term="csharp" /><summary type="html">I’m going to share a quick tip on how to easily create strings of a fixed length. For example suppose you have two strings like this.</summary></entry><entry><title type="html">trying out avalonia</title><link href="https://jweiler.com/avalonia/2023/03/01/trying-out-avalonia.html" rel="alternate" type="text/html" title="trying out avalonia" /><published>2023-03-01T10:04:29+00:00</published><updated>2023-03-01T10:04:29+00:00</updated><id>https://jweiler.com/avalonia/2023/03/01/trying-out-avalonia</id><content type="html" xml:base="https://jweiler.com/avalonia/2023/03/01/trying-out-avalonia.html">&lt;p&gt;###A simple overview of what Avalonia is.&lt;/p&gt;

&lt;p&gt;I’ve heard about &lt;a href=&quot;https://avaloniaui.net/&quot;&gt;Avalonia&lt;/a&gt; recently and thought I want to write about about trying it out. It allow you to create Multi-Platform Apps with .NET using xaml. Xaml is one of the things I really enjoyed while working on WPF applications so that certainly sounds interesting to me.&lt;/p&gt;

&lt;p&gt;They have a helpful &lt;a href=&quot;https://docs.avaloniaui.net/docs/getting-started&quot;&gt;getting started page&lt;/a&gt; to quickly get a sample running. To get started you will want to run the following command to install the templates:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dotnet new install Avalonia.Templates&lt;/code&gt;
After doing that if you go to Visual Studio and create a new project you should see options for creating an Avalonia project:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/2023-03-01-avalonia1.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;If you select the .NET Core App you will get a simple application with a MainWindow.axaml file. (.axaml is the extension for Avalonia views).&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-xaml&quot;&gt;&amp;lt;Window xmlns=&quot;https://github.com/avaloniaui&quot;
        xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
        xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
        xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
        mc:Ignorable=&quot;d&quot; d:DesignWidth=&quot;800&quot; d:DesignHeight=&quot;450&quot;
        x:Class=&quot;AvaloniaApplication1.MainWindow&quot;
        Title=&quot;AvaloniaApplication1&quot;&amp;gt;
    Welcome to Avalonia!
&amp;lt;/Window&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you are familiar with WPF at all you will notice this is very much the same.&lt;/p&gt;

&lt;p&gt;In the Program class you will see things look a little different than a typical WPF application.&lt;/p&gt;

&lt;div class=&quot;language-csharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;internal&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Program&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// Initialization code. Don't use any Avalonia, third-party APIs or any&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// SynchronizationContext-reliant code before AppMain is called: things aren't initialized&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// yet and stuff might break.&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;STAThread&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;BuildAvaloniaApp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;StartWithClassicDesktopLifetime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// Avalonia configuration, don't remove; also used by visual designer.&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AppBuilder&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;BuildAvaloniaApp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AppBuilder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Configure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;()&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;UsePlatformDetect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;LogToTrace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;When you run the application you should see a window show with the “Welcome to Avalonia!” text appear in it.&lt;/p&gt;

&lt;p&gt;If you were looking at their docs you may have noticed there also is webassembly support which allows your app to run in the browser as well! This is not ready for production yet, but if you want to check that out see &lt;a href=&quot;https://docs.avaloniaui.net/tutorials/running-in-the-browser&quot;&gt;this docs page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you go back and create an application using their MVVM template you will see something more familiar if MVVM is what you typically use.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/2023-03-01-avalonia2.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This is just a simple overview but I find the project very interesting. While many people may not like the idea of using xaml to create user interfaces, to me it is appealing and makes Avalonia attractive to me.&lt;/p&gt;

&lt;p&gt;They do have a &lt;a href=&quot;https://docs.avaloniaui.net/misc/projects-that-are-using-avalonia&quot;&gt;list of projects&lt;/a&gt; that use Avalonia so be sure to check them out. Also if you use Jetbrains Rider Avalonia is nicely &lt;a href=&quot;https://docs.avaloniaui.net/docs/getting-started/ide-support/jetbrains-rider-setup&quot;&gt;integrated into there&lt;/a&gt; as well.&lt;/p&gt;</content><author><name></name></author><category term="avalonia" /><summary type="html">###A simple overview of what Avalonia is.</summary></entry><entry><title type="html">using azure translator api</title><link href="https://jweiler.com/azure/2023/02/21/using-azure-translator-api.html" rel="alternate" type="text/html" title="using azure translator api" /><published>2023-02-21T10:04:29+00:00</published><updated>2023-02-21T10:04:29+00:00</updated><id>https://jweiler.com/azure/2023/02/21/using-azure-translator-api</id><content type="html" xml:base="https://jweiler.com/azure/2023/02/21/using-azure-translator-api.html">&lt;p&gt;The Azure Translator service is very handy if you have some text you need to translate from one language to another. There is more that 100 languages available. See the whole list here.&lt;/p&gt;

&lt;p&gt;After creating a Translator resource in Azure it’s very easy to get started translating text. You will need a Key and the Endpoint which can be found on the Keys and Endpoints tab:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/2023-02-21-translator1.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;With C# the code to translate some text is quite simple:&lt;/p&gt;

&lt;div class=&quot;language-csharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;route&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;/translate?api-version=3.0&amp;amp;from=zh-Hans&amp;amp;to=en&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Text&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;textToTranslate&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;requestBody&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;JsonConvert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;SerializeObject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;client&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;HttpClient&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;HttpRequestMessage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// Build the request.&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Method&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;HttpMethod&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Post&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RequestUri&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Uri&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;https://api.cognitive.microsofttranslator.com/&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;route&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Content&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;StringContent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;requestBody&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Encoding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;UTF8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;application/json&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Headers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Ocp-Apim-Subscription-Key&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;myKey&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Headers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Ocp-Apim-Subscription-Region&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;eastus&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;client&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;SendAsync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Content&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ReadAsStringAsync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;It’s important to note that in my route variable I specify my from and to languages.&lt;/p&gt;

&lt;p&gt;Then the result will be a json string that contains the translated results.&lt;/p&gt;

&lt;p&gt;You can also try out the translator service from the overview tab of the Azure resource. This will show you what the response should look like from the API:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/2023-02-21-translator2.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;</content><author><name></name></author><category term="azure" /><summary type="html">The Azure Translator service is very handy if you have some text you need to translate from one language to another. There is more that 100 languages available. See the whole list here.</summary></entry><entry><title type="html">visual studio tip - tracepoint</title><link href="https://jweiler.com/visualstudio/2023/02/03/visual-studio-tip-tracepoint.html" rel="alternate" type="text/html" title="visual studio tip - tracepoint" /><published>2023-02-03T10:04:29+00:00</published><updated>2023-02-03T10:04:29+00:00</updated><id>https://jweiler.com/visualstudio/2023/02/03/visual-studio-tip-tracepoint</id><content type="html" xml:base="https://jweiler.com/visualstudio/2023/02/03/visual-studio-tip-tracepoint.html">&lt;p&gt;Today is a short post with a Visual Studio feature that can come in really handle when debugging code.
I’m sure you have used Breakpoints many times in Visual Studio&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/2023-02-03-tracepoint1.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Tracepoints are somewhat similar but also different. To create one right click on the left side of your Visual Studio window (where you would usually left click to create a breakpoint).&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/2023-02-03-tracepoint2.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;That will give you a window like below.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/2023-02-03-tracepoint3.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Then when you run your application you will see a line in the Output window everytime the tracepoint is hit.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/2023-02-03-tracepoint4.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This example may be a bit simple, but if you can imagine an application where you are debugging various keyboard input for example this feature can make it very easy to see what is happening with out needing to stop program execution to inspect variables.&lt;/p&gt;</content><author><name></name></author><category term="visualstudio" /><summary type="html">Today is a short post with a Visual Studio feature that can come in really handle when debugging code. I’m sure you have used Breakpoints many times in Visual Studio</summary></entry><entry><title type="html">Getting started with Rebus</title><link href="https://jweiler.com/rebus/2023/01/24/getting-started-with-rebus.html" rel="alternate" type="text/html" title="Getting started with Rebus" /><published>2023-01-24T10:04:29+00:00</published><updated>2023-01-24T10:04:29+00:00</updated><id>https://jweiler.com/rebus/2023/01/24/getting-started-with-rebus</id><content type="html" xml:base="https://jweiler.com/rebus/2023/01/24/getting-started-with-rebus.html">&lt;h2 id=&quot;learn-how-to-use-rebus-with-an-in-memory-transport&quot;&gt;Learn how to use Rebus with an in memory transport.&lt;/h2&gt;

&lt;p&gt;I saw &lt;a href=&quot;https://rebus.fm/what-is-rebus/&quot;&gt;Rebus&lt;/a&gt; some time ago and thought it would be interesting to take a look at. Rebus is often used as an abstraction for things like Azure Service Bus and RabbitMQ, but it can also be used with in memory queues.&lt;/p&gt;

&lt;p&gt;To get it installed in your project run the following command:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Install-Package Rebus -ProjectName &amp;lt;your-project&amp;gt;&lt;/code&gt;
I’m going to show a simple implementation within a console application. You can set it up like this:&lt;/p&gt;

&lt;div class=&quot;language-csharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;activator&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;BuiltinHandlerActivator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;Configure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;With&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;activator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Transport&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;UseInMemoryTransport&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;InMemNetwork&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;test-queue&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Logging&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Start&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;I told it to use the in memory transport option and specified a name of the queue. At this point I could send a message like this:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;await activator.Bus.SendLocal(50);&lt;/code&gt;
But nothing would be listening for an integer message yet because we haven’t setup any message handlers. Let’s say we want to handle a birthday event. We can create a class like this:&lt;/p&gt;

&lt;div class=&quot;language-csharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;HandleBirthdayEvent&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IHandleMessages&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Birthday&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Task&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Birthday&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;birthday&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;Console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;WriteLine&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;$&quot;Congrats &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;birthday&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; on turning &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;birthday&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CompletedTask&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Before we send the message we need to register our new HandleBirthdayEvent like this:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;activator.Register(() =&amp;gt; new HandleBirthdayEvent());&lt;/code&gt;
Then we can send the message to ourself with SendLocal like this:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;await activator.Bus.SendLocal(new Birthday {  Name = &quot;Bob&quot;, Age = 50});&lt;/code&gt;
Then we should see a Console.WriteLine message.&lt;/p&gt;

&lt;p&gt;There are other ways to send a message. If we wanted to go a particular queue we could use this method to do so.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;await activator.Bus.Advanced.Routing.Send(&quot;test-queue&quot;, new Birthday { Name = &quot;Bob&quot;, Age = 50 });&lt;/code&gt;
Or another way is to configure Routing and to do it based on type we could add this to the Configure of rebus.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.Routing(r =&amp;gt; r.TypeBased().Map&amp;lt;Birthday&amp;gt;(&quot;test-queue&quot;))&lt;/code&gt;
Then we could simply send the message like this:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;await activator.Bus.Send(new Birthday { Name = &quot;Bob&quot;, Age = 50 });	&lt;/code&gt;
Because we configured the routing to use the test-queue for type Birthday we don’t need to specify what queue we are sending to when we send the message.&lt;/p&gt;

&lt;p&gt;Now to use this in real world application you would typically register Rebus with the .NET service provider just like many other things are added into your app. There is a big list of &lt;a href=&quot;https://github.com/rebus-org/RebusSamples&quot;&gt;samples&lt;/a&gt; that you should check out to get ideas of what you could all use Rebus for.&lt;/p&gt;</content><author><name></name></author><category term="rebus" /><summary type="html">Learn how to use Rebus with an in memory transport.</summary></entry><entry><title type="html">Other uses of git interactive rebase</title><link href="https://jweiler.com/git/2023/01/11/more-git-interctive-rebase.html" rel="alternate" type="text/html" title="Other uses of git interactive rebase" /><published>2023-01-11T10:04:29+00:00</published><updated>2023-01-11T10:04:29+00:00</updated><id>https://jweiler.com/git/2023/01/11/more-git-interctive-rebase</id><content type="html" xml:base="https://jweiler.com/git/2023/01/11/more-git-interctive-rebase.html">&lt;h2 id=&quot;more-git-interactive-rebase&quot;&gt;More Git Interactive Rebase&lt;/h2&gt;

&lt;p&gt;This will be an extension of my previous post about using git interactive rebase to change the author of a git commit. If you followed through that you probably noticed that you can do a lot more than just change a commit author.&lt;/p&gt;

&lt;p&gt;If you do a git interactive rebase you will see the following commands listed as a possibilty for you to use:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# Commands:
# p, pick &amp;lt;commit&amp;gt; = use commit
# r, reword &amp;lt;commit&amp;gt; = use commit, but edit the commit message
# e, edit &amp;lt;commit&amp;gt; = use commit, but stop for amending
# s, squash &amp;lt;commit&amp;gt; = use commit, but meld into previous commit
# f, fixup &amp;lt;commit&amp;gt; = like &quot;squash&quot;, but discard this commit's log message
# x, exec &amp;lt;commit&amp;gt; = run command (the rest of the line) using shell
# d, drop &amp;lt;commit&amp;gt; = remove commit
# l, label &amp;lt;label&amp;gt; = label current HEAD with a name
# t, reset &amp;lt;label&amp;gt; = reset HEAD to a label
# m, merge [-C &amp;lt;commit&amp;gt; | -c &amp;lt;commit&amp;gt;] &amp;lt;label&amp;gt; [# &amp;lt;oneline&amp;gt;]
# .       create a merge commit using the original merge commit's
# .       message (or the oneline, if no original merge commit was
# .       specified). Use -c &amp;lt;commit&amp;gt; to reword the commit message.
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Those are fairly self explanatory but let’s quickly walk through how to change a commit message.&lt;/p&gt;

&lt;p&gt;Run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git log&lt;/code&gt; to find the commit ID of the commit just before the one you want to change the message for.&lt;/p&gt;

&lt;p&gt;Then run this:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git rebase -i -p &amp;lt;previousCommitID&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You should see something like this in your editor.
&lt;img src=&quot;/assets/images/2023-01-11 15_46_40-git-rebase-todo.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Find the ones you want to change the commit message and change pick to reword. Save your editor and close it. Then for each reword it will re-open your editor and allow you to change the message. Save and close it when done.&lt;/p&gt;

&lt;p&gt;For my example I altered a commit message for a commit that was pushed remotely so I will force push.&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git push -f origin &amp;lt;branch-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name></name></author><category term="git" /><summary type="html">More Git Interactive Rebase</summary></entry></feed>