Abstract:
A software testing tool is presented, which uses dependency analysis to greatly optimize the process of running tests.
A software testing tool is presented, which uses dependency analysis to greatly optimize the process of running tests.
A mechanism is described for automatically converting method invocations of
any programmatic interface into a single-method normal form and
converting back to invocations of the original interface, so that
general-purpose operations can be performed on the normal form without
explicit knowledge of the interface being invoked. Implementations are
provided for C# and for Java.
My notes on how to use SVG graphics in a WPF application
The goal is to be able do do things like this:
... where mySvgImage somehow stands for a vector image that has somehow been obtained from an SVG file.
The solution must not involve any proprietary, closed-source libraries.
Naturally, we want one of the following:
namespace Test14 { class Test { interface A { void F(); } interface B: A { } class C: B { void A.F() //OK { } void B.F() //error CS0539: 'B.F' in explicit interface declaration is not a member of interface { } } } }
namespace Test12 { class Test { public static bool Equals<T>( T a, T b ) where T: class { return object.Equals( a, b ); } public static bool Equals<T>( T a, T b ) where T: struct //error CS0111: Type 'Test' already defines a member called 'Equals' with the same parameter types { return a.Equals( b ); } } }
namespace Test11 { class Test { public enum myenum { a, b, c } void test_myenum( myenum f, int i ) { i = (int)myenum.a; //need to cast; that's good. f = (myenum)5; //need to cast; that's still good. f = 0; //wtf? no need to cast? } } }
namespace Test10 { class Test { void statement() { } void test( int a ) { /* with "indent case contents" option selected: */ switch( a ) { case 42: /* this is not properly indented */ { statement(); break; } default: /* this is properly indented */ statement(); break; } /* with "indent case contents" option deselected: */ switch( a ) { case 42: /* this is properly indented */ { statement(); break; } default: /* this is not properly indented */ statement(); break; } /* the normal way of indenting cannot be achieved: */ switch( a ) { case 42: { statement(); break; } default: statement(); break; } } } }
namespace Test9 { class Test { void statement() { } void wtf_is_it_with_falling_through_the_last_case_label( int a ) { switch( a ) { case 42: statement(); break; default: statement(); break; //Need this 'break' or else: CS0163: Control cannot fall through from one case label ('default:') to another } } } }
namespace Test8 { class Test { void statement() { } void test() { if( true ) //no warning about 'condition is always true'. statement(); while( false ) //no warning about 'condition is always false', even though the compiler obviously knows what's going on, since the following warning is issued: statement(); //warning CS0162: Unreachable code detected } } }
namespace Test7 { class Test { private void unused() //no warning about unused private method. { } } }
namespace Test6 { class Test { void moo( int a ) //no warning about unused parameter 'a'. { } } }
namespace Test5 { public class Test { public int a; void foo() { for( int i = 0; i < 10; i++ ) { a = 10; //error CS0844: Cannot use local variable 'a' before it is declared. The declaration of the local variable hides the field 'Test5.Test.a'. } string a = ""; Console.WriteLine( a ); } } }
namespace Test4 { class Test { void test() { if( this != null ) { object o; o = null; if( o == this ) return; } object o; //error CS0136: A local variable named 'o' cannot be declared in this scope because it would give a different meaning to 'o', which is already used in a 'child' scope to denote something else } } }
namespace Test3 { public class Test { public readonly string m = "m"; public string n = "n"; private string o = "o"; protected readonly string p = "p"; protected string q = "p"; private string r = "r"; Test() { m = "m2"; //Blooper: no warning about field having already been initialized. n = "n2"; //Blooper: no warning about field having already been initialized. o = "o2"; //Blooper: no warning about field having already been initialized. p = "p2"; //Blooper: no warning about field having already been initialized. q = "q2"; //Blooper: no warning about field having already been initialized. r = "r2"; //Blooper: no warning about field having already been initialized. o.ToLower(); //to prevent Warning CS0414: The field is assigned but its value is never used. r.ToLower(); //to prevent Warning CS0414: The field is assigned but its value is never used. } } }
namespace Test2 { public class Test { public readonly string m; public string n; protected readonly string o; protected string p; private readonly string q; private string r; Test() { m.ToUpper(); //Blooper: no warning about accessing uninitialized member. n.ToUpper(); //Blooper: no warning about accessing uninitialized member. o.ToUpper(); //Blooper: no warning about accessing uninitialized member. p.ToUpper(); //Blooper: no warning about accessing uninitialized member. q.ToUpper(); //Blooper: no warning about accessing uninitialized member. r.ToUpper(); //Blooper: no warning about accessing uninitialized member. q = "q"; //to prevent Warning CS0649: Field is never assigned to, and will always have its default value null r = "r"; //to prevent Warning CS0649: Field is never assigned to, and will always have its default value null } } }
namespace Test1 { class Test1 { #if TRY_IT public readonly int m; //OK: warning CS0649: Field is never assigned to, and will always have its default value 0 protected readonly int n; //OK: warning CS0649: Field is never assigned to, and will always have its default value 0 internal readonly int o; //OK: warning CS0649: Field is never assigned to, and will always have its default value 0 private readonly int p; //OK: warning CS0649: Field is never assigned to, and will always have its default value 0 protected internal readonly int q; //OK: warning CS0649: Field is never assigned to, and will always have its default value 0 Test1() { if( p != 0 ) //To avoid warning 'The field is never used' return; } #endif } public class Test2 { #if TRY_IT private readonly int m; //OK: warning CS0649: Field is never assigned to, and will always have its default value 0 internal readonly int n; //OK: warning CS0649: Field is never assigned to, and will always have its default value 0 Test2() { if( m != 0 ) //To avoid warning 'The field is never used' return; } #endif public readonly int o; //Blooper: no warning about field never assigned to. protected readonly int p; //Blooper: no warning about field never assigned to. protected internal readonly int q; //Blooper: no warning about field never assigned to. } public sealed class Test3 { public readonly int m; //Blooper: no warning about field never assigned to. } }
Compiler Warning (level 4) CS0649:
Field 'field' is never assigned to, and will always have its default value 'value'
The compiler detected an uninitialized private or internal field declaration that is never assigned a value.
A mechanism is proposed for converting (entwining) method call invocations of any interface to a general purpose single-method normal form, and converting back (untwining) from the normal form to interface invocations, so that operations can be performed on the normal form in a way agnostic to the interface being invoked. The normal form is a delegate in C# or a functional interface in Java, realized as object AnyCall( int selector, object[] parameters ). A DotNet implementation is provided in C#, though the discussion also applies to Java.