Couldn't help but detect a hint of malevolence in the depiction of faith, so here's my own more reasonable version in response:
A common scenario in C# I find is that I would like to:
I still want them to show up as warnings, which is to say that I don't want them to disappear altogether. 'CS0618 Obsolete' is a good example of this.
This cannot be achieved through the C# Project Properties editor, but it can be done by manually editing the .csproj file to add these two MSBuild properties:
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsNotAsErrors>618</WarningsNotAsErrors>
This is vaguely referred to in the docs here, and the list of error codes can be found here.
Setting up a new computer I somehow managed to break Visual Studio macros. Finally found this, which fixed it. (See the Workaround tab).
Basically delete this magical file, then rerun the VS installer:
%ProgramFiles(x86)%\Microsoft Visual Studio 9.0\Common7\IDE\1033\Microsoft.VSDesignerUI.dll
I'm working in Silverlight 4, and have been trying to get a particular binding scenario to work right. It seems to be the case that try to satisfy any one or two requirements is easy enough, but when things start piling up, Silverlight can get a bit tricky.
My requirements:
The problems:
So here's what I've got working. It's disgusting, but seems to work.
<UserControl>
...
<ContentControl x:Name="content"/>
<ContentControl.ContentTemplate>
<DataTemplate>
<TextBox Text="{Binding Self.SomeValue}" />
</DataTemplate>
<ContentControl.ContentTemplate>
</ContentControl>
...
</UserControl>
And the code...
public partial class MyControl : UserControl
{
public class Indirection
{
public ValueEditor Self { get; set; }
}
public MyControl()
{
InitializeComponent();
this.content.Content = new Indirection() { Self = this };
}
public static readonly DependencyProperty SomeValueProperty = ...
public string SomeValue { ... }
}
So the idea is to set the ContentControl.Content to a proxy object that is not the control itself, but with a reference to the control, which can then be accessed in the path of the binding.
If you know a nicer way to do this, please leave a comment!
How disappointing! I've just started to dip a toe into C# default parameters. And they have to be compile-time constants. Sure, it makes a lot of sense, but how about allowing static readonly properties as well?
All I want is this:
// Not too much to ask for?
void MyMethod(Guid someId = Guid.Empty)
{
...
}
Way back in the '80s I cut my programmers teeth on a Microbee 32k. Back on a classy green and black CRT, with an audio cassettes for permanent storage.
One of the things I remember noticing was that while playing a tune (1-bit square wave), if I held down a key on the keyboard that the frequency would drop slightly. This was presumably due to the poor 2MHz CPU having to stop counting how long it has spent on each waveform to go and service the keyboard IRQ. How quaint.
Now, as I sit at a PC that's at between three and five orders of magnitude more powerful, depending on the measure, I've just noticed an errily familiar behavior.
With my sound turn up, I hear a faint low-pitched hum even though no sound is playing. Now, whenever I move my mouse it turns into a faint high-pitched squeal. I actually get one of two high pitches depending on how fast I'm moving the mouse.
Not 100% sure what's going on here, but as they're USB powered speakers, I'm guessing that the transmission of mousing data is causing some interference on the power rail. I guess it shouldn't be surprising given that people have figured out how to capture keystrokes from EM emissions.
I've never really worried about getting into Visual Studio code snippets. But I've been using INotifyPropertyChanged a lot recently, so it got me looking at them again.
Found this cool snippet by Brian Schroer for filling out properties. Here's my slightly customized version of it to suit personal taste. Thanks Brian!
Steps to intall:
Steps to use:
The code:
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>propn</Title>
<Shortcut>propn</Shortcut>
<Description>Code snippet for property and backing field in class implementing INotifyPropertyChanged</Description>
<Author>Brian Schroer</Author>
<!-- http://geekswithblogs.net/brians/archive/2010/07/27/inotifypropertychanged-with-less-typing-using-a-code-snippet.aspx -->
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>Property type</ToolTip>
<Default>string</Default>
</Literal>
<Literal>
<ID>property</ID>
<ToolTip>Property name</ToolTip>
<Default>MyProperty</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[/// <summary>
/// Gets or sets the $property$
/// </summary>
public $type$ $property$
{
get { return _$property$;}
set
{
if (value != _$property$)
{
_$property$ = value;
OnPropertyChanged("$property$");
}
}
}
private $type$ _$property$;
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>