Simon Cooper

Follow Simon Cooper via

03 January 2014
03 January 2014

C# via Java: Arrays

0
1
The one primitive type that hasn’t been covered is the array. An array contains a fixed number of items, and each item is a value of the array’s element type. The array elements are individually indexed starting from zero. In comparison to the other primitive types, which are all value types, arrays are reference types. … Read more
0
1
26 November 2013
26 November 2013

C# via Java: Primitive types

0
4
So, what is a primitive type? According to the Incompleteness Theorem, there will always be things in any mathematical system, and therefore any computational system, that cannot be defined using the rules of that system. These rules form the axioms of that system. For Java and C#, the axioms are the rules of the language … Read more
0
4
08 November 2013
08 November 2013

C# via Java: Introduction

0
0
So, I’ve recently changed jobs. Rather than working in .NET land, I’ve migrated over to Java land. But never fear! I’ll continue to peer under the covers of .NET, but my next series will use my new experience in Java to explore the design decisions made in the development of the C# programming language. After … Read more
0
0
03 June 2013
03 June 2013

Why unhandled exceptions are useful

0
1
It’s the bane of most programmers’ lives – an unhandled exception causes your application or webapp to crash, an ugly dialog gets displayed to the user, and they come complaining to you. Then, somehow, you need to figure out what went wrong. Hopefully, you’ve got a log file, or some other way of reporting unhandled … Read more
0
1
28 May 2013
28 May 2013

.NET Security Part 4

0
0
Finally, in this series, I am going to cover some of the security issues that can trip you up when using sandboxed appdomains. DISCLAIMER: I am not a security expert, and this is by no means an exhaustive list. If you actually are writing security-critical code, then get a proper security audit of your code … Read more
0
0
16 May 2013
16 May 2013

.NET Security Part 3

0
0
You write a security-related application that allows addins to be used. These addins (as dlls) can be downloaded from anywhere, and, if allowed to run full-trust, could open a security hole in your application. So you want to restrict what the addin dlls can do, using a sandboxed appdomain, as explained in my previous posts. … Read more
0
0
07 May 2013
07 May 2013

.NET Security Part 2

0
2
So, how do you create partial-trust appdomains? Where do you come across them? There are two main situations in which your assembly runs as partially-trusted using the Microsoft .NET stack: Creating a CLR assembly in SQL Server with anything other than the UNSAFE permission set. The permissions available in each permission set are given here. … Read more
0
2
19 April 2013
19 April 2013

Inside Portable Class Libraries

0
0
Portable Class Libraries were introduced with Visual Studio 2010 SP1 to aid writing libraries that could be used on many different platforms – the full .NET 4/4.5 framework, Windows Phone, Silverlight, Xbox, and Windows Store apps. You simply select which platforms and versions you want to target, then the available subset of APIs are magically … Read more
0
0
20 August 2012
20 August 2012

Inside the DLR – Invoking methods

0
2
So, we’ve looked at how a dynamic call is represented in a compiled assembly, and how the dynamic lookup is performed at runtime. The last piece of the puzzle is how the resolved method gets invoked, and that is the subject of this post. Invoking methods As discussed in my previous posts, doing a full … Read more
0
2
03 August 2012
03 August 2012

Inside the DLR – Callsite binders

0
8
So, we’ve looked at how the C# compiler produces a CallSite object for every dynamic call that is made, and provides it with everything it needs to resolve the call at runtime. How is this information used when the callsite is invoked? To create a CallSite object, you need to pass in an instance of … Read more
0
8
23 July 2012
23 July 2012

Inside the DLR – Callsites

0
2
The DLR was introduced in .NET 4 to allow dynamic languages, like Python or Ruby, to run on the CLR. The DLR is also used by C# 4, released at the same time, to implement dynamic binding via the dynamic keyword. In this post, I’ll be looking at what exactly happens when you issue a … Read more
0
2
31 May 2012
31 May 2012

PostSharp, Obfuscation, and IL

0
1
Aspect-oriented programming (AOP) is a relatively new programming paradigm. Originating at Xerox PARC in 1994, the paradigm was first made available for general-purpose development as an extension to Java in 2001. From there, it has quickly been adapted for use in all the common languages used today. In the .NET world, one of the primary … Read more
0
1
04 May 2012
04 May 2012

Inside Red Gate – Ricky Leeks

0
0
So, one of our profilers has a problem. Red Gate produces two .NET profilers – ANTS Performance Profiler (APP) and ANTS Memory Profiler (AMP). Both products help .NET developers solve problems they are virtually guaranteed to encounter at some point in their careers – slow code, and high memory usage, respectively. Everyone understands slow code … Read more
0
0
03 May 2012
03 May 2012

Subterranean IL: The ThreadLocal type

I came across ThreadLocal<T> while I was researching ConcurrentBag. To look at it, it doesn’t really make much sense. What’s all those extra Cn classes doing in there? Why is there a GenericHolder<T,U,V,W> class? What’s going on? However, digging deeper, it’s a rather ingenious solution to a tricky problem. Thread statics Declaring that a variable … Read more
16 April 2012
16 April 2012

Obfuscation is not a panacea

0
0
So, you want to obfuscate your .NET application. My question to you is: Why? What are your aims when your obfuscate your application? To protect your IP & algorithms? Prevent crackers from breaking your licensing? Your boss says you need to? To give you a warm fuzzy feeling inside? Obfuscating code correctly can be tricky, … Read more
0
0
28 March 2012
28 March 2012

.NET vs Windows 8

0
0
So, day 1 of DevWeek. Lots and lots of Windows 8 and WinRT, as you would expect. The keynote had some actual content in it, fleshed out some of the details of how your apps linked into the Metro infrastructure, and confirmed that there would indeed be an enterprise version of the app store available … Read more
0
0
26 March 2012
26 March 2012

Inside the Concurrent Collections: ConcurrentBag

0
6
Unlike the other concurrent collections, ConcurrentBag does not really have a non-concurrent analogy. As stated in the MSDN documentation, ConcurrentBag is optimised for the situation where the same thread is both producing and consuming items from the collection. We’ll see how this is the case as we take a closer look. Again, I recommend you … Read more
0
6
26 March 2012
26 March 2012

DevWeek 2012

0
0
For those interested, myself and a few other people from Red Gate will be going to DevWeek 2012 in London this week. I’ll be mostly around the .NET and C# talks, but may drop into the architecture and agile talks as well. I’ll be blogging interesting stuff I come across as well. If you want … Read more
0
0
08 March 2012
08 March 2012

Why you shouldn’t add methods to interfaces in APIs

0
0
It is an oft-repeated maxim that you shouldn’t add methods to a publically-released interface in an API. Recently, I was hit hard when this wasn’t followed. As part of the work on ApplicationMetrics, I’ve been implementing auto-reporting of MVC action methods; whenever an action was called on a controller, ApplicationMetrics would automatically report it without … Read more
0
0