Skip to content

Instantly share code, notes, and snippets.

@cathode
Created April 16, 2013 19:32
Show Gist options
  • Select an option

  • Save cathode/5398880 to your computer and use it in GitHub Desktop.

Select an option

Save cathode/5398880 to your computer and use it in GitHub Desktop.
Code contracts static analyzer is complaining about "Warning 2411 CodeContracts: Possibly calling a method on a null reference C:\Users\cathode\Documents\Visual Studio 2012\Projects\nsynth\source\NSynth\FilterInputFrames.cs 47 35 NSynth" on line 21. Presumably it thinks "owner" might be null, which I dont see how it could be.
/// <summary>
/// Initializes a new instance of the <see cref="FilterInputFrames"/> class.
/// </summary>
/// <param name="owner">The filter that is rendering a frame to which the input frames will be used.</param>
/// <param name="currentIndex">The frame index being rendered.</param>
public FilterInputFrames(Filter owner, long currentIndex)
{
Contract.Requires(owner != null);
Contract.Requires(currentIndex >= 0);
this.locker = new object();
this.currentIndex = currentIndex;
this.owner = owner;
this.frames = new Dictionary<string, Dictionary<long, Frame>>();
foreach (var slot in owner.Inputs)
{
var neededFrames = new Dictionary<long, Frame>();
// Build a list of indices of frames we need for each input slot.
foreach (var i in owner.GetInputFramesRequired(slot, currentIndex))
neededFrames.Add(i, null);
this.frames.Add(slot.Name, neededFrames);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment