Saturday, September 19

Check your access modifier

 When your dependency injector container can't find a constructor for your class, you might want to check that the constructor for the class is public.

Monday, July 6

C# Struct

Struct is a value type.
The first difference between a reference types and value types is that reference types are allocated on the heap and value types are allocated inline or on the stack. The are deallocated when the stack unwinds or when the containing type gets deallocated. Therefore, allocated and deallocated is generally cheaper.

The second difference is related to memory usage. Value types get boxed when cast to a reference type or one of the interfaces they implement. They get unboxed when east back to the value type. Because boxes are objects that are allocated on the heap and are garbage collected. Too much boxing and unboxing can have a negative impact on the heap.

Third, reference types assignments copy the reference, whereas value type assignments copy the entire value.

Fourth, reference types are passed by reference, where as types are passed by value.

Sunday, January 27

no test is available in visual studio

This error showed up after adding a new class to a test project.

using Microsoft.VisualStudio.TestTools.UnitTesting;
using DateTime;

namespace UnitTestDateTime
{
    [TestClass]
    class UnitTestDate
    {
        [TestMethod]
        public void TestDayOfTheWeek()
        {
            Date date = new Date(1, 27, 2019);
            Assert.AreEqual("Sunday", date.DayOfTheWeek());
        }
    }
}

[1/27/2019 9:18:19 AM Informational] ------ Discover test started ------
[1/27/2019 9:18:23 AM Warning] [MSTest][Discovery][C:\Users\tjmad\source\repos\DateTime\UnitTestDateTime\bin\Debug\netcoreapp2.1\UnitTestDateTime.dll] UTA001: TestClass attribute defined on non-public class UnitTestDateTime.UnitTestDate
[1/27/2019 9:18:23 AM Warning] No test is available in C:\Users\tjmad\source\repos\DateTime\UnitTestDateTime\bin\Debug\netcoreapp2.1\UnitTestDateTime.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[1/27/2019 9:18:24 AM Warning] No test is available in C:\Users\tjmad\source\repos\DateTime\UnitTestDateTime\UnitTestDateTime.csproj. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[1/27/2019 9:18:24 AM Informational] ========== Discover test finished: 0 found (0:00:05.451639) ==========
[1/27/2019 9:18:24 AM Informational] ------ Run test started ------
[1/27/2019 9:18:26 AM Warning] [MSTest][Discovery][C:\Users\tjmad\source\repos\DateTime\UnitTestDateTime\bin\Debug\netcoreapp2.1\UnitTestDateTime.dll] UTA001: TestClass attribute defined on non-public class UnitTestDateTime.UnitTestDate
[1/27/2019 9:18:26 AM Warning] No test is available in C:\Users\tjmad\source\repos\DateTime\UnitTestDateTime\bin\Debug\netcoreapp2.1\UnitTestDateTime.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[1/27/2019 9:18:27 AM Warning] No test is available in C:\Users\tjmad\source\repos\DateTime\DateTime\DateTime.csproj C:\Users\tjmad\source\repos\DateTime\UnitTestDateTime\UnitTestDateTime.csproj. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[1/27/2019 9:18:27 AM Informational] ========== Run test finished: 0 run (0:00:03.1466992) ==========

The solution was simple. The class needed to be public.
using Microsoft.VisualStudio.TestTools.UnitTesting;
using DateTime;

namespace UnitTestDateTime
{
    [TestClass]
    public class UnitTestDate
    {
        [TestMethod]
        public void TestDayOfTheWeek()
        {
            Date date = new Date(1, 27, 2019);
            Assert.AreEqual("Sunday", date.DayOfTheWeek());

        }

    }
}

Tuesday, October 30

World Famous Starship Captain

I decided to create an animation of Snoopy as Captain Kirk combined with the sound of warp drive acceleration. I used this picture as a base.
Image result for world famous starship captain

I removed Woodstock from it and darkened the background.

The next step was to cut Snoopy and the doghouse out of the background and fill in the background.
 




Next, I used MS Paint to skew Snoopy to about 20 degrees. The sound file was 30 seconds long, and at 24 frames per second made for 720 total frames. Dividing that out came to about a degree every 20 frames.























Each of these were combined with the background. Then I used a Java program to fill in the gaps.

/**
 * @author Tim Madden
 *
 */

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;

public class CopyFile {

public static void main(String[] args) {
int[] skew = {0, 1, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608,
640, 672, 704, 720, 721 };
// String src = "D:/Shared/My Pictures/1 Blender Models/Snoopy/Sequence";
File source;
File dest;
String destString, sourceString;

try {
for (int x = 1; x < skew.length; x++) {
sourceString = String.format("D:/Shared/My Pictures/1 Blender Models/Snoopy/Sequence/%04d.png", skew[x]);
System.out.println(sourceString);
source = new File(sourceString);
for (int i = skew[x]; i < skew[x + 1]; i++) {
destString = String.format("D:/Shared/My Pictures/1 Blender Models/Snoopy/Output/%04d.png", i);
System.out.println("\t" + destString);
dest = new File(destString);
Files.copy(source.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING);
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

/*
* try { for (int i = 1; i < 281; i++) { destString =
* String.format("/Users/tjmad/OneDrive/Pictures/Cloak/Image Sequence/%04d.png",
* i); dest = new File(destString); Files.copy(source.toPath(), dest.toPath(),
* StandardCopyOption.REPLACE_EXISTING); } } catch (IOException e) { // TODO
* Auto-generated catch block e.printStackTrace(); }
*/
}

}

I then thought it would be good to have a title card. 
Blender was used to put the sequences together with the sound file.

And the end result:


Sunday, June 17

UWP Support for .NET Standard 2.0, fixing the NU120 message

To fix the NU1201 for Universal Windows Program such as:
NU1201: Project WeatherApp is not compatible with uap10.0.10586 (UAP,Version=v10.0.10586). Project WeatherApp supports: netstandard2.0 (.NETStandard,Version=v2.0)
NU1201: Project WeatherApp is not compatible with uap10.0.10586 (UAP,Version=v10.0.10586) / win10-arm. Project WeatherApp supports: netstandard2.0 (.NETStandard,Version=v2.0)
NU1201: Project WeatherApp is not compatible with uap10.0.10586 (UAP,Version=v10.0.10586) / win10-arm-aot. Project WeatherApp supports: netstandard2.0 (.NETStandard,Version=v2.0)
NU1201: Project WeatherApp is not compatible with uap10.0.10586 (UAP,Version=v10.0.10586) / win10-x64. Project WeatherApp supports: netstandard2.0 (.NETStandard,Version=v2.0)
NU1201: Project WeatherApp is not compatible with uap10.0.10586 (UAP,Version=v10.0.10586) / win10-x64-aot. Project WeatherApp supports: netstandard2.0 (.NETStandard,Version=v2.0)
NU1201: Project WeatherApp is not compatible with uap10.0.10586 (UAP,Version=v10.0.10586) / win10-x86. Project WeatherApp supports: netstandard2.0 (.NETStandard,Version=v2.0)
NU1201: Project WeatherApp is not compatible with uap10.0.10586 (UAP,Version=v10.0.10586) / win10-x86-aot. Project WeatherApp supports: netstandard2.0 (.NETStandard,Version=v2.0)


You need to set the Minimum Version in the Project properties to Windows 10 Fall Creator Update (10.0; Build 16299).


Thursday, February 1

Procedural star field in Blender

In the right-hand panel, turn off Reflective Caustics and Refractive Caustics under Scene.



Go to the World setting in the right-hand panel

Move mouse cursor to bottom of menu on the window at the line, until it changes to a double ended arrow.

Slide the window up to make it larger.

Change the bottom view to the node editor.

Switch to World at the bottom.

Click on the Use Nodes in the right-hand panel.

Add a Noise Texture

Set the Scale of the Noise Texture to 500 or so.


Add a ColorRamp

Add a MixRGB node.

Set the top color of the MixRGB node to black


Connect the Color output of the Noise Texture to the Color2 input of the MixRGB node.

Connect the Color output of the Noise Texture to the Fac input of the ColorRamp.

Connect the Color output of the ColorRamp to the Fac of the MixRGB node.

Connect the Color output of the MixRGB node to the Color input of the Background node.

Change the upper window to Rendered

Adjust the sliders on the ColorRamp to get the look you want.

The further to the right the black slider is, the more black the background. The further to the left the white 
slider is the more stars.

And use the Detail in to Noise Texture to control the number of stars.

To add different size stars, hold Shift and select the Noise Texture and the ColorRamp, then press Shift-D to Duplicate.

Change the scale of the second Noise Texture to a lower value.

Add another MixRGB node between the first one and the first ColorRamp node.


Connect the Color output of the top ColorRamp to the top Color input of the new MixRGB node. Connect the Color output of the bottom ColorRamp to the bottom Color input of the new MixRGB node.


Change the new MixRGB to Add.