<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[Visual Studio - Greg Shackles]]></title><description><![CDATA[Visual Studio - Greg Shackles]]></description><link>https://gregshackles.com/</link><image><url>https://gregshackles.com/favicon.png</url><title>Visual Studio - Greg Shackles</title><link>https://gregshackles.com/</link></image><generator>Ghost 4.32</generator><lastBuildDate>Tue, 02 Jun 2026 08:16:04 GMT</lastBuildDate><atom:link href="https://gregshackles.com/tag/visual-studio/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Looking Ahead to Xamarin.Forms 3.0]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>It&apos;s been a few years now since Xamarin.Forms was released into the world, and it continues to be a popular and evolving framework choice for Xamarin developers. Later this year Microsoft is planning to release Xamarin.Forms 3.0, its third major release of the framework, which</p>]]></description><link>https://gregshackles.com/looking-ahead-to-xamarin-forms-3-0/</link><guid isPermaLink="false">61ce48a0437e8200017d4156</guid><category><![CDATA[Visual Studio]]></category><category><![CDATA[Xamarin]]></category><category><![CDATA[Xamarin.Forms]]></category><dc:creator><![CDATA[Greg Shackles]]></dc:creator><pubDate>Fri, 11 Aug 2017 13:21:31 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>It&apos;s been a few years now since Xamarin.Forms was released into the world, and it continues to be a popular and evolving framework choice for Xamarin developers. Later this year Microsoft is planning to release Xamarin.Forms 3.0, its third major release of the framework, which is slated to ship with a lot of exciting features and improvements. While it certainly won&apos;t be comprehensive, as the feature set is large and still in motion, in this article I&apos;ll walk through some of the highlights of what&apos;s coming later this year for Xamarin.Forms developers.</p>
<p>Read the rest over at <a href="https://visualstudiomagazine.com/articles/2017/08/01/xamarinforms3_0.aspx">Visual Studio Magazine</a>.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Visual Studio Mobile Center: A Better Way To Build Mobile Apps]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>If you&apos;re building a mobile app, there&apos;s a lot of things you need to set up. How do you build and distribute your app? How do you authenticate your users? Do you have some sort of backend set up to store your data? How are you</p>]]></description><link>https://gregshackles.com/visual-studio-mobile-center-a-better-way-to-build-mobile-apps/</link><guid isPermaLink="false">61ce48a0437e8200017d4151</guid><category><![CDATA[Visual Studio]]></category><category><![CDATA[Xamarin]]></category><category><![CDATA[Mobile Center]]></category><dc:creator><![CDATA[Greg Shackles]]></dc:creator><pubDate>Mon, 15 May 2017 17:07:46 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>If you&apos;re building a mobile app, there&apos;s a lot of things you need to set up. How do you build and distribute your app? How do you authenticate your users? Do you have some sort of backend set up to store your data? How are you monitoring errors and usage? The list goes on and on.</p>
<p>Microsoft has a lot of different offerings targeting these very needs. There&apos;s Xamarin Insights for crash reporting and monitoring, Test Cloud for device testing, HockeyApp for distribution, Azure Mobile Services for storage and authentication, and Visual Studio Team Services for builds. These are great options, but it&apos;s still a lot to piece together for every app you need to manage. Microsoft recently introduced a new product to help consolidate the story: Visual Studio Mobile Center.</p>
<p>Mobile Center takes all of these separate services and unifies them into a single cohesive experience, allowing you to manage your builds, tests, monitoring, and back-end services in the same place.</p>
<p>Read the rest of the article over at <a href="https://visualstudiomagazine.com/articles/2017/05/09/visual-studio-mobile-center.aspx">Visual Studio Magazine</a></p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[You, Too, Can Build Xamarin Apps with F#]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>A couple years back I wrote <a href="https://visualstudiomagazine.com/articles/2014/11/01/polyglot-apps.aspx">an article</a> covering how you could leverage many different languages in your Xamarin apps. In it, I included an F# portable class library that was referenced by the main application written in C#. That&apos;s still a completely valid approach, but I thought</p>]]></description><link>https://gregshackles.com/you-too-can-build-xamarin-apps-with-f/</link><guid isPermaLink="false">61ce48a0437e8200017d414e</guid><category><![CDATA[Visual Studio]]></category><category><![CDATA[Xamarin]]></category><category><![CDATA[F#]]></category><category><![CDATA[Xamarin.Forms]]></category><dc:creator><![CDATA[Greg Shackles]]></dc:creator><pubDate>Fri, 13 Jan 2017 15:01:25 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>A couple years back I wrote <a href="https://visualstudiomagazine.com/articles/2014/11/01/polyglot-apps.aspx">an article</a> covering how you could leverage many different languages in your Xamarin apps. In it, I included an F# portable class library that was referenced by the main application written in C#. That&apos;s still a completely valid approach, but I thought it was a good time to follow that up with a look at how, these days, you can use F# to build the entire app, and why it&apos;s a great fit.</p>
<p>F# often gets typecast as being useful for things in the math or science realms, due to its type system and built-in support for things like units, but what often gets lost in the conversation is how great it can be for &quot;normal&quot; everyday applications, as well.</p>
<p>This article isn&apos;t meant to be a real introduction to the F# language or its many features. Instead, I&apos;ll provide a quick look at how you can use F# to concisely define an application using the same underlying frameworks you&apos;d be using from C#. No prior F# exposure is needed here, so don&apos;t worry if you&apos;re brand new to it.</p>
<p>Read the rest of the article over at <a href="https://visualstudiomagazine.com/articles/2017/01/01/build-xamarin-apps.aspx">Visual Studio Magazine</a>.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Composable Customizations with Xamarin.Forms]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>In the early days of Xamarin.Forms, if you wanted to start customizing any of the built-in controls in ways beyond what were explicitly exposed on those controls, you probably found yourself creating a lot of custom renderers. Renderers can be a great way to hook into the Xamarin.Forms</p>]]></description><link>https://gregshackles.com/composable-customizations-with-xamarin-forms/</link><guid isPermaLink="false">61ce48a0437e8200017d4142</guid><category><![CDATA[Visual Studio]]></category><category><![CDATA[Xamarin]]></category><category><![CDATA[Xamarin.Forms]]></category><dc:creator><![CDATA[Greg Shackles]]></dc:creator><pubDate>Thu, 04 Aug 2016 18:30:24 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>In the early days of Xamarin.Forms, if you wanted to start customizing any of the built-in controls in ways beyond what were explicitly exposed on those controls, you probably found yourself creating a lot of custom renderers. Renderers can be a great way to hook into the Xamarin.Forms rendering pipeline and inject your own customizations, but it can quickly get unwieldy if you do it a lot, and is often a larger hammer than you would want to be swinging.</p>
<p>In more recent versions of Xamarin.Forms, the concepts of behaviors and effects were introduced that make these types of customizations much more approachable. In contrast to renderers, where you can only have a single implementation for any given control, behaviors and effects allow you to define customizations at a much more granular level. In addition, you can add any number of behaviors and effects to a control, meaning you can compose them together to get the outcome for which you&apos;re looking.</p>
<p>Read the rest of the article over at <a href="https://visualstudiomagazine.com/articles/2016/08/01/composable-customizations.aspx">Visual Studio Magazine</a>.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Using IronPython to Enforce Code Conventions in Visual Studio Builds]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>Recently I was reading a <a href="http://weblogs.asp.net/scottgu/archive/2010/04/06/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2.aspx">blog post by Scott Guthrie</a> about the new syntax for HTML encoding output in ASP.NET 4, where he said the following:</p>
<blockquote>
<p>This enables you to default to always using &lt;%: %&gt; code nuggets instead of &lt;%= %&gt; code blocks within your applications. If you</p></blockquote>]]></description><link>https://gregshackles.com/using-ironpython-to-enforce-code-conventions-in-visual-studio-builds/</link><guid isPermaLink="false">61ce48a0437e8200017d40f9</guid><category><![CDATA[IronPython]]></category><category><![CDATA[Python]]></category><category><![CDATA[Visual Studio]]></category><dc:creator><![CDATA[Greg Shackles]]></dc:creator><pubDate>Sun, 18 Apr 2010 13:00:00 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>Recently I was reading a <a href="http://weblogs.asp.net/scottgu/archive/2010/04/06/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2.aspx">blog post by Scott Guthrie</a> about the new syntax for HTML encoding output in ASP.NET 4, where he said the following:</p>
<blockquote>
<p>This enables you to default to always using &lt;%: %&gt; code nuggets instead of &lt;%= %&gt; code blocks within your applications. If you want to be really hardcore you can even create a build rule that searches your application looking for &lt;%= %&gt; usages and flags any cases it finds as an error to enforce that HTML encoding always takes place.</p>
</blockquote>
<p>It seemed like a fun exercise, so I decided to take up the challenge and build a simple rules engine for enforcing code conventions as part of the build. I know there already exist some tools out there for doing this, such as <a href="http://code.msdn.microsoft.com/sourceanalysis">StyleCop</a>, and they almost certainly do it more comprehensively than what I implemented. However, I thought this would be a good example of how easy it is to extend the build process with your own custom checks.</p>
<p>I&#x2019;ve developed a bit of a habit lately of using <a href="http://ironpython.net/">IronPython</a> whenever I would normally create a new console application. You get all the benefits of the .NET Framework, and the conveniences of a dynamic language. If you haven&#x2019;t played with it at all, I would highly suggest doing so since dynamic languages are really takin off in the .NET space.</p>
<p>To start off, I had to decide what it was I wanted to try and enforce in my build. I decided to keep it simple, and have a list of rules that said which file types it should check, and what string it would search the files for. Again, in keeping it simple, I decided to just do a line-by-line check, so violations that wrap over a line break would not get caught. For basic checks, this is more than sufficient.</p>
<h2 id="theenforcer">The Enforcer</h2>
<p>First, let&#x2019;s start writing the IronPython script to do the work for us.</p>
<pre><code class="language-language-python">import System
from System.IO import *

# assuming that we got one command line argument, which is the base
# directory to start processing in
base_dir = System.Environment.GetCommandLineArgs()[2]
</code></pre>
<p>Now we imported the namespaces we need, and grabbed the base project directory from the command line arguments. As you can see, even though Python has its own methods of accessing command line arguments, we&#x2019;re going to stick with the .NET methods.</p>
<p>Next, we&#x2019;ll establish the structure for the rules:</p>
<pre><code class="language-language-python">rules = [
        {
            &quot;extensions&quot;: [ &quot;aspx&quot;, &quot;ascx&quot;, &quot;Master&quot; ],
            &quot;searchTerm&quot;: &quot;&lt;b&gt;&quot;,
            &quot;type&quot;: &quot;Warning&quot;,
            &quot;message&quot;: &quot;Please use &apos;strong&apos; instead of &apos;b&apos;.&quot;
        },
        {
            &quot;extensions&quot;: [ &quot;aspx&quot;, &quot;ascx&quot;, &quot;Master&quot; ],
            &quot;searchTerm&quot;: &quot;&lt;i&gt;&quot;,
            &quot;type&quot;: &quot;Warning&quot;,
            &quot;message&quot;: &quot;Please use &apos;em&apos; instead of &apos;i&apos;.&quot;
        }
    ]
</code></pre>
<p>Each rule has a list of extensions it applies to, the string to look for, the type of violation it is (can be either &#x201C;Warning&#x201D; or &#x201C;Error), and the message to display in the build error. The first two examples there will look for the old style bold and italic tags, and warn you that there are better tags to use.</p>
<p>Next, let&#x2019;s define a function that given a file and a rule, will check for violations of the rule within that file.</p>
<pre><code class="language-language-python">def process_file(file, rule):
line_number = 0
line = None

reader = StreamReader(file)
line = reader.ReadLine()

while line != None:
    line_number += 1

    # does this line violate the rule?
    if line.ToLower().Contains(rule[&quot;searchTerm&quot;].ToLower()):
        System.Console.WriteLine(&quot;%s (%d): %s: %s&quot; % (file, line_number, rule[&quot;type&quot;], rule[&quot;message&quot;]))

    line = reader.ReadLine()

reader.Close()
</code></pre>
<p>You might be wondering why the only thing we do when we find a violation is to print it out. As it turns out, if a post-build step outputs something in the correct format, Visual Studio will treat it as an error or warning as appropriate. Including the line number makes it so that double clicking on the error brings you to the offending line. That&#x2019;s all there is to it!</p>
<p>Now we just need to call that function on all the rules and corresponding files. For each extension found in the rules, we&#x2019;ll create a bucket of all the rules that apply to it to help narrow down the number of file reads we need to do.</p>
<pre><code class="language-language-python"># explode the rules out to a dictionary with one key per extension
rule_buckets = {}

for rule in rules:
    for extension in rule[&quot;extensions&quot;]:
        if not extension in rule_buckets:
            rule_buckets[extension] = [ rule ]
        else:
            rule_buckets[extension].append(rule)

# now start checking the rules, one extension at a time
for extension in rule_buckets:
    for file in Directory.GetFiles(base_dir, &quot;*.&quot; + extension, SearchOption.AllDirectories):
        for rule in rule_buckets[extension]:
            process_file(file, rule)
</code></pre>
<h2 id="postbuildhook">Post-Build Hook</h2>
<p><img src="https://gregshackles.com/content/images/2014/12/BuildEvents.jpg" alt="post-build hook" loading="lazy"></p>
<p>All that&#x2019;s left is to plug this script into the post-build process of our project. In the properties section for your project (right click on the project in Visual Studio and click on Properties) go to the Build Events tab. Under &#x201C;Post-build event command line&#x201D; enter the following:</p>
<pre><code>&quot;C:\Program Files (x86)\IronPython 2.6\ipy.exe&quot; &quot;C:\projects\Scripts\convention-enforcer.py&quot; &quot;$(SolutionDir)\$(ProjectName)&quot;
</code></pre>
<p>Obviously, replace the paths for IronPython and the python script with your own. For the &#x201C;Run the post-build event&#x201D; setting immediately afterwards, choose for it to run &#x201C;On Successful build.&#x201D; There is no reason to run these checks on a build that already failed for other reasons. The macros in the command will make sure that the checks are limited to files within the current project.</p>
<h2 id="testingtherules">Testing the Rules</h2>
<p>So now we have our rule enforcer tied into our project, but does it work? Let&#x2019;s give it a test run. Earlier we defined a couple rules to check for bold and italic tags, so we&#x2019;ll try those out. I created a new MVC project, and created a master page that contains this:</p>
<pre><code class="language-language-html">&lt;b&gt;This is some bold text&lt;/b&gt;
</code></pre>
<p>I also created a view containing the following:</p>
<pre><code class="language-language-html">&lt;i&gt;This is some italicized text.&lt;/i&gt;
</code></pre>
<p>Very uninteresting, but these are just test cases. When building the project, Visual Studio now reports warnings for both of these lines.</p>
<p><img src="https://gregshackles.com/content/images/2014/12/Error-BoldItalic.jpg" alt="bold/italic error" loading="lazy"></p>
<h2 id="morerules">More Rules</h2>
<p>As I mentioned earlier, this post was inspired by the Scott Guthrie post about a new tag for properly encoding HTML output, so naturally we should implement that rule. First, we extend the rules in the IronPython script to include:</p>
<pre><code class="language-language-python">{
    &quot;extensions&quot;: [ &quot;aspx&quot;, &quot;ascx&quot;, &quot;Master&quot; ],
    &quot;searchTerm&quot;: &quot;&lt;%=&quot;,
    &quot;type&quot;: &quot;Error&quot;,
    &quot;message&quot;: &quot;For security reasons, please use &apos;&lt;%:&apos; instead of &apos;&lt;%=&apos;.&quot;
}
</code></pre>
<p>Now add this line to the view:</p>
<pre><code class="language-language-aspnet">&lt;%= ViewData[&quot;Data&quot;] %&gt;
</code></pre>
<p>As expected, the build now breaks with an error about using the outdated tag.</p>
<p><img src="https://gregshackles.com/content/images/2014/12/Error-Encoding.jpg" alt="outdated tag error" loading="lazy"></p>
<p>So far, all of the rules have been for frontend code files, so just for completeness let&#x2019;s include a rule for a C# file. Perhaps you&#x2019;re a pure old school developer who refuses to embrace all of this new fangled LINQ voodoo. You can now toss in a rule to the script that breaks the build if the System.Linq namespace is imported. Using this rule:</p>
<pre><code class="language-language-python">{
    &quot;extensions&quot;: [ &quot;cs&quot; ],
    &quot;searchTerm&quot;: &quot;using System.Linq&quot;,
    &quot;type&quot;: &quot;Error&quot;,
    &quot;message&quot;: &quot;When I was your age, we didn&apos;t have any fancy LINQ to help us.&quot;
}
</code></pre>
<p>Now, though I wouldn&#x2019;t recommend it, your build will break once the namespace gets imported.</p>
<p><img src="https://gregshackles.com/content/images/2014/12/Error-Linq.jpg" alt="LINQ error" loading="lazy"></p>
<p>And there you have it. By mixing some IronPython with the Visual Studio build process, we created a simple and extensible engine for quick convention checks on every successful build.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item></channel></rss>