NDC London 2018

Last week I attended NDC London. It’s not the first time that I’ve been, but it is the first time I’ve done the workshops that run alongside the main conference.

I attended the “Identity & Access Control for modern Applications and APIs using ASP.NET Core 2” workshop hosted by Dominick Baier and Brock Allen. This was a two day workshop consisting of a mixture of presentation, discussion, and hands-on labs. It dived deep into the security aspects of modern ASP.Net applications, specifically the application itself and its APIs. The first day focused on how external authentication (via OAuth 2.0 and OpenID Connect) could be used to save having to implement authentication yourself in your application. The second day took this further and focused on how to secure an API that you may have in an application so that you can call it server-to-server, from mobile applications, or from JavaScript applications.

The remaining three days of the conference was in the form of talks. Like I’ve done before, I sketchnoted many of the sessions that I attended.

What Is Programming Anyway?

by Felienne Hermans Website Twitter Video

What Is Programming Anyway? by Felienne Hermans

The Power Of Technical Decisions

by Jake Ginnivan Website Twitter Video

The Power Of Technical Decisions by Jake Ginnivan

You Build It, You Run It

by Chris O’Dell Website Twitter Video

You Build It, You Run It by Chris O'Dell

An Introduction To Kotlin

by Dmitry Kandalov Website Twitter Slides Video

An Introduction To Kotlin by Dmitry Kandalov

Composite UIs: The Microservices Last Mile

by Jimmy Bogard Website Twitter Slides Video

Composite UIs: The Microservices Last Mile by Jimmy Bogard

Designing For Speech

by Jessice Engström Website Twitter Video

Designing For Speech by Jessica Engström

Jewelbots: How To Get More Girls Coding

by Jennifer Wadella Website Twitter Slides Video

Jewelbots: How To Get More Girls Coding by Jennifer Wadella

Who Needs Dashboards?

by Jessica White Website Twitter Slides Video

Who Needs Dashboards? by Jessica White

Pilot Decision Management

by Clifford Agius Twitter Video

Pilot Decision Management by Clifford Agius

A Developer’s Guide To Machine Learning

by Tess Ferrandez-Norlander Website Twitter Slides Video

A Developer's Guide To Machine Learning by Tess Ferrandez

CSP XXP STS PKP CAA ETC…

by Scott Helme Website Twitter Video

CSP XXP STS PKP CAA ETC... by Scott Hulme

Web Apps Can’t Do That, Can They?

by Steve Sanderson Website Twitter Video

Web Apps Can't Do That, Can They? by Steve Sanderson

These are the other talks I attended but didn’t sketchnote:

C# 7.0

by Jon Skeet Website Twitter Video

C# 7.1 and 7.2: The Releases You Didn’t Know You Had

by Bill Wagner Website Twitter Video

The Psychology Of Social Engineering

by Niall Merrigan Website Twitter Video

The Modern Cloud

by Scott Guthrie Website Twitter Video

The Hello World Show Live

hosted by Heather Downing and Spencer Schneidenbach Website Video

Tips And Tricks With Azure

by Scott Guthrie Website Twitter Video

Why I’m Not Leaving .Net

by Mark Rendle Website Twitter Video


DDD North 2017

I recently attended DDD North 2017 in Bradford. I’ve been wanting to take up sketchnoting for a while now, but have never gotten round to doing it, so when Ian Johnson (go check out his sketchnotes - they are great) prompted me to take my sketchbook and pens with me, I reluctantly obliged. I’m so glad I did though as I really enjoyed doing them, and I feel it had the effect of me being able to recall much more of the content of each talk. I tweeted the sketchnotes after each session and got a great response from both the speakers and attendees.

Here are the sketchnotes I did during the day.

Microservices: What I’ve Learned After A Year Of Building A System

by Nathan Gloyn Website Twitter Slides

Microservices: What I've Learned After A Year Of Building A System by Nathan Gloyn

Spot The Difference: Automating Visual Regression Testing

by Viv Richards Website Twitter Slides

Spot The Difference: Automating Visual Regression Testing by Viv Richards

Married To The Mob (Programming)

by Derek Graham Website Twitter Slides

Married To The Mob (Programming) by Derek Graham

How To Parse A File

by Matt Ellis Website Twitter Slides

How To Parse A File by Matt Ellis

Alexa, Open Sneezaroo…

by Zinat Wali Twitter

Alexa, Open Sneezaroo... by Zinat Wali


Setting a culture for all threads in an application

If you do any kind of globalisation in your applications, you will probably already be familiar with the Thread.CurrentCulture and Thread.CurrentUICulture properties that can be used to set a culture on the thread so that .Net knows to load the correct resources and to format numbers and dates properly.

A big downside to using approach this is that the culture is only set on the current thread, meaning that any new threads created will be using the default culture for the application (which is tied to the regional settings of the operation system). This wasn’t too much of a problem years ago when multi-threading was not used widely, but in modern application development it is virtually impossible to avoid using multiple threads (e.g. Task Parallel Library), especially when trying to make use of modern multi-core hardware. You would have to manually set the culture when spawning new threads to ensure that the correct culture was being used - a real pain and a common cause of bugs.

.Net 4.5 comes to the rescue with the introduction of two new properties:

CultureInfo.DefaultThreadCurrentCulture
CultureInfo.DefaultThreadCurrentUICulture

A culture can be set using properties that will then be used for all threads in the whole application domain, meaning that you can set the correct culture at application start up and all threads will use that culture. By default, these properties are set to null meaning that the pre-4.5 behaviour will still hold and that the system culture will be used by default.

The MSDN docs for CultureInfo.DefaultThreadCurrentCulture and CultureInfo.DefaultThreadCurrentUICulture provide more details.


Alternatives to .Net Reflector

RedGate recently announced that from the next version of Reflector (v7), they will charge $35 for a licence. Since the announcement a few weeks ago, there has been quite a backlash against the decision from the .Net community, mainly because RedGate have put a time-bomb in the currently-free version so that it will expire at the end of May 2011. In response to this announcement, several alternatives to Reflector have surfaced - some free, some commercial. The list below outlines all of the alternatives, some of which have been around for many years.

  • JetBrains ReSharper (commercial + free)
    Within a day of the announcement, JetBrains put out a teaser suggesting that a decompiler was in the works. Two weeks later, they announced that the next version of ReSharper will have an integrated decompiler akin to reflector, along with a free standalone version to be released later in the year.

  • Telerik JustCode (commercial)
    Just as JetBrains put out a teaser, Telerik followed suit and showed a decompilation feature that will be in the next version of their JustCode tool.

  • ldasm (free)
    This tool comes bundled with the Windows SDK Tools (that get installed as part of Visual Studio). It is purely an IL disassembler, and so cannot decompile to C#.

  • ILSpy (free)
    The team behind SharpDevelop have been working hard on ILSpy and have already released a major milestone of v1 of their decompiler. It can decompile to C#.

  • Cecil Studio (free)
    This is a Windows forms UI based on the Mono Cecil library. It has already been around for a few years.

  • MonoReflector (free)
    This is a WPF UI based on the Mono Cecil library.

  • MonoDevelop Assembly Browser (free)
    Released for the first time in version 2.0 of MonoDevelop (currently at v2.4.2).

  • Salamander .Net Decompiler (commercial)
    This is part of a larger tool called .Net Explorer.

  • Dis# (commercial)
    This tool has been around for a while, but is not often mentioned. It is not as polished as Reflector and does not support never versions of .Net, but has some nice features not seen anywhere else. Once such feature is to rename the decompiled variables within the tool to give them a more meaningful name.

  • Spices .Net Decompiler (commercial)
    As well as decompiling to IL, C#, J#, C++ and Delphi.Net, this tool has a feature to build code flow diagrams from the decompiled source to show the execution flow.

  • Decompiler.NET (commercial)
    This is s decompiler combined with an obfuscator, language translator and refactoring tool that integrates with Visual Studio.

  • Keep Decompiling Free
    This website popped up recently with nothing more than a teaser to get more information when it is available.

  • RedGate Reflector (commercial)
    Of course, there is still the current king of them all, albeit in a now charged-for format. Still well worth the $35.

Which of these will turn out to be the best/most successful to take Reflector’s throne is yet to play out, but there seems to be a healthy interest from both the community and commercial aspects in making a replacement.


Temporarily disabling ReSharper

I have ReSharper installed and think it is a great tool for productivity, but occasionally I find it useful to temporarily disable it to speed up Visual Studio (especially so on my old, slow laptop). This is achieved in two different ways, depending on the version of ReSharper.

In versions prior to version 5, ReSharper appears in the Add-in Manager dialog, accessed via the Tools menu. Using this dialog, you can uncheck the ReSharper add-in which will suspend it (the menu will still be visible, but its functionality will be disabled).

Add-in manager

Checking it again will re-enable it. Both of these actions can be performed without restarting Visual Studio.

In version 5, ReSharper no longer appears in the add-ins dialog. At first glance, I though the ability to disable ReSharper was no longer available. As it turns out, it is now part of ReSharper itself and is accessed via the Tools -> Options -> ReSharper -> General dialog. Clicking the suspend button will suspend ReSharper and disable its functionality. Once suspended, clicking the resume button will re-enable it.

ReSharper options

This applies to all versions of Visual Studio - the difference is based on the version of ReSharper only.


Extracting MSI files (revisited)

A few years ago, I posted about how to extract the contents of an MSI file without having to go through the process of installing it. The tool used to do this was called Less MSIerables. This tool does do the job, but the UI is a bit clunky to use, it has a few bugs, and occasionally fails to extract the contents of a file. On top of this, it looks like this tool is not actively developed (it was last updated in 2005), so I recently started to look for an alternative.

It turns out that Microsoft provide this functionality as part of MSIExec that comes as part of the Windows installer. To extract the contents of any MSI file, simply run the following:

msiexec.exe /a installer.msi /qb TARGETDIR=C:\temp

This will extract the complete contents of the MSI file to the specified directory.


MSDN lightweight view

Following on from my last post on the MDSN Low Bandwidth View, Scott Hanselman recently tweeted about the beta version of MDSN Lightweight View.

In a similar way to adding (loband) before the .aspx part of the url, putting (lightweight) before the .aspx part of the url will use the new lightweight view of MSDN, meaning a much neater and streamlined version.

In addition, Scott has previously posted about the other modes of MSDN:

Mode Description Example
- The normal MSDN view Example
(loband) A minimal view, focussed on speed Example
(lightweight) A faster lightweight view, including quick links to switch between languages and .Net framework versions Example
(pda) Aimed at PDAs and phones. Turns off the tree and allows a 100% width Example
(robot) Optimised for search engines Example
(printer) A printable version Example
(ide) Used when viewing inside the IDE. Adds send and give feedback links Example

Note that the dev10ide view Scott mentions seems to have been removed, and that the lightweight view is currently in beta, so may be liable to change.


MSDN low bandwidth view

Several months ago, I read a tip about passing an extra parameter on the url to MSDN documentation to put it into “low bandwidth” mode. I remember doing it at the time, but almost immediately forgot the url switch. That was until last week when I read Eric Nelson’s post on how to do it.

The trick is to put (loband) before the .aspx part of the url. For example, the low bandwidth version of

http://msdn.microsoft.com/en-us/library/system.object.aspx

becomes

http://msdn.microsoft.com/en-us/library/system.object(loband).aspx

Once you have accessed it, you can persist it by clicking on the “Persist low bandwidth view” link.

Since Eric wrote his post, it seems that a “Switch on low bandwidth view” link has been added into the normal MSDN pages to enable it to be switched on without hacking around with the url.

Jon Galloway has a post that summarises the benefits of the low bandwidth view. For me, the biggest benefit is the speed of loading, since the page doesn’t run lots of JavaScript to sync the contents tree to the currently displayed article.


SQL Server SP3 released

Service pack 3 for SQL Server 2005 was released last week. In it, they have fixed a curious bug that I reported back in January.

The bug occurs when trying to delete rows from a table that has a NULL value for an image column. This works fine normally, but if there is a foreign key referencing the table (to any of its columns), any rows that have had their image column updated to be NULL fail to be deleted. This SQL demonstrates the problem:

-- create two linked tables
CREATE TABLE [dbo].[TableA]
(
    [Identity] [int] NOT NULL IDENTITY(1, 1) PRIMARY KEY,
    [TableB_Identity] [int] NULL
)

CREATE TABLE [dbo].[TableB]
(
    [Identity] [int] NOT NULL IDENTITY(1, 1) PRIMARY KEY,
    [DATA] image NULL
)

ALTER TABLE [TableA] ADD CONSTRAINT [FK_TableA_TableB] 
    FOREIGN KEY ([TableB_Identity]) REFERENCES [TableB] ([Identity])

-- insert some data
INSERT INTO [TableB] ([DATA]) VALUES (NULL)
INSERT INTO [TableB] ([DATA]) VALUES (NULL)
INSERT INTO [TableB] ([DATA]) VALUES (NULL)

-- this delete works successfully
DELETE FROM [TableB] WHERE [DATA] IS NULL
SELECT COUNT(*) AS Remaining_Count_Should_Be_0 FROM [TableB]

-- insert some data
INSERT INTO [TableB] ([DATA]) VALUES (NULL)
INSERT INTO [TableB] ([DATA]) VALUES (NULL)
INSERT INTO [TableB] ([DATA]) VALUES (NULL)

-- update the data to be have a NULL value
UPDATE [TableB] SET [DATA] = NULL WHERE [DATA] IS NULL

-- this delete doesn't work
DELETE FROM [TableB] WHERE [DATA] IS NULL
SELECT COUNT(*) AS Remaining_Count_Should_Be_0 FROM [TableB]

-- this delete doesn't work
DELETE FROM [TableB] WHERE ISNULL([DATA], NULL) IS NULL
SELECT COUNT(*) AS Remaining_Count_Should_Be_0 FROM [TableB]

-- this delete does work successfully
DELETE FROM [TableB] WHERE EXISTS
    (
        SELECT * FROM [TableB] AS TB
        WHERE [DATA] IS NULL 
        AND TB.[Identity] = [TableB].[Identity]
    )
SELECT COUNT(*) AS Remaining_Count_Should_Be_0 FROM [TableB]

Not all of the delete queries work correctly. The output of the script is four result sets with the count of how many rows are in the table at each point. All of them should be 0 (as is the case on SQL Server 2000), but in SQL Server 2005 without SP3 they are actually 0, 3, 3 and 0.

The simple delete query:

DELETE FROM [TableB] WHERE [DATA] IS NULL

does not delete any rows after the values for the Data column have been updated to NULL, even though a similar select query:

SELECT * FROM [TableB] WHERE [DATA] IS NULL

Notably, if either the foreign key is removed, or the:

UPDATE [TableB] SET [DATA] = NULL WHERE [DATA] IS NULL

query is not performed, the script behaves as expected. Additionally, using text or ntext instead of image does not work as well, but using the new varchar(max), nvarchar(max) or varbinary(max) data types does work.

Apparrently, the distinction between NULL values stored as a result of an insert or an update has precendece in the WRITETEXT command:

If the table does not have in row text, SQL Server saves space by not initializing text columns when explicit or implicit null values are added in text columns with INSERT, and no text pointer can be obtained for such nulls. To initialize text columns to NULL, use the UPDATE statement. If the table has in row text, you do not have to initialize the text column for nulls and you can always get a text pointer.

This points to the “text in row” option having a bearing on this behaviour. Indeed, altering this option after creating the tables:

sp_tableoption N'TableB', 'text in row', 'ON'

results in the script working as expected. Useful as a potential workaround.

The bug is present in all versions of SQL Server 2005, but not in SQL Server 2000 or 2008.

A full list of what’s changed in SP3 can be found here, with a full list of the bugs fixed here.