public void Read2(int start, int end) { Parallel.For(start, end, i => { SimpleFile.Read(); }); }
public void Test() { Assert.DoesNotThrow( () => { SimpleFile.Read(); SimpleFile.Read(); }); Assert.DoesNotThrow( delegate() { SimpleFile.Read(); SimpleFile.Read(); }); Runner.RunWithParameter( obj => { SimpleFile.Read(); SimpleFile.Read(); }); #pragma warning disable CS0168 // Variable is declared but never used #pragma warning disable CS8321 // Local function is declared but never used void LocalDoubleRead() #pragma warning restore CS8321 // Local function is declared but never used #pragma warning restore CS0168 // Variable is declared but never used { SimpleFile.Read(); SimpleFile.Read(); } }
public void Read3() { Assert.DoesNotThrow(() => { SimpleFile.Read(); }); }
public void Test() { if (Success) { SimpleFile.Read(); } }
public void Read() { Parallel.ForEach(new [] { "" }, i => { SimpleFile.Read(); }); }
public void Test(string value, IDisposable item) { if (value == null) { throw new ArgumentNullException(nameof(value)); } SimpleFile.Read(); switch (item) { case BinaryReader br: value = "test"; break; case Stream _: value = "test2"; break; default: throw new InvalidOperationException(); } switch (value) { case "test": return; default: throw new InvalidOperationException(); } }
public void Read2() { if (DateTime.Today.Hour > 9) { SimpleFile.Read(); } }
public void Read() { Parallel.For(1, 100, i => { SimpleFile.Read(); }); }
public void Test() { Assert.That(1, Is.EqualTo(1)); Assert.That(() => { SimpleFile.Read(); return(true); }, Is.EqualTo(true)); Assert.That(() => { SimpleFile.Read(); return(true); }); Assert.That(() => { SimpleFile.Read(); }, Throws.Nothing); Assert.That(() => { Console.WriteLine(""); }, Throws.Nothing); var result = false; Assert.That(() => result = SimpleFile.Write(""), Throws.Nothing); Assert.IsTrue(result); }
public void Test() { lock (typeof(Lock)) { SimpleFile.Read(); } lock (typeof(Lock)) { Console.WriteLine("Test"); } lock (typeof(Lock)) SimpleFile.Read(); lock (_lock) { lock (typeof(Lock)) { SimpleFile.Read(); } lock (StaticLock) { SimpleFile.Read(); } } lock (_lock) SimpleFile.Read(); }
public void InvalidOperationException() { throw new InvalidOperationException("Invalid"); #pragma warning disable 162 SimpleFile.Read(); #pragma warning restore 162 }
public void Read() { if (IsValid) { SimpleFile.Read(); } }
public void Read() { var nested = NestedFactory.Create(); nested.DoSomething(); SimpleFile.Read(); }
public void TestAfterAnalyzation() { var readFile = GetMethodName(o => o.ReadFile); var callReadFile = GetMethodName(o => o.CallReadFile); var callCallReadFile = GetMethodName(o => o.CallCallReadFile); var read = GetMethodName(() => SimpleFile.Read()); var readAsync = GetMethodName(() => SimpleFile.ReadAsync()); var generator = new AsyncCodeGenerator(); Action <IProjectAnalyzationResult> afterAnalyzationFn = result => { Assert.AreEqual(1, result.Documents.Count); Assert.AreEqual(1, result.Documents[0].Namespaces.Count); Assert.AreEqual(1, result.Documents[0].Namespaces[0].Types.Count); Assert.AreEqual(3, result.Documents[0].Namespaces[0].Types[0].Methods.Count); var methods = result.Documents[0].Namespaces[0].Types[0].Methods.ToDictionary(o => o.Symbol.Name); Assert.IsTrue(methods[readFile].OmitAsync); // Check InvokedBy Assert.AreEqual(1, methods[readFile].InvokedBy.Count); Assert.AreEqual(methods[callReadFile], methods[readFile].InvokedBy[0]); Assert.AreEqual(1, methods[callReadFile].InvokedBy.Count); Assert.AreEqual(0, methods[callCallReadFile].InvokedBy.Count); // Check MethodReferences Assert.AreEqual(1, methods[readFile].MethodReferences.Count); var methodReference = methods[readFile].MethodReferences[0]; Assert.AreEqual(SyntaxKind.InvocationExpression, methodReference.ReferenceNode.Kind()); Assert.IsFalse(methodReference.Ignore); Assert.IsFalse(methodReference.AwaitInvocation); Assert.IsTrue(methodReference.UseAsReturnValue); Assert.IsNull(methodReference.ReferenceFunctionData); Assert.AreEqual(read, methodReference.ReferenceSymbol.Name); Assert.AreEqual(1, methodReference.ReferenceAsyncSymbols.Count); Assert.AreEqual(readAsync, methodReference.ReferenceAsyncSymbols[0].Name); // Check Conversion Assert.AreEqual(MethodConversion.ToAsync, methods[readFile].Conversion); Assert.AreEqual(MethodConversion.ToAsync, methods[callReadFile].Conversion); Assert.AreEqual(MethodConversion.ToAsync, methods[callCallReadFile].Conversion); }; var methodConversions = new[] { MethodConversion.ToAsync, MethodConversion.Smart }; foreach (var methodConversion in methodConversions) { var config = Configure(p => p .ConfigureAnalyzation(a => a .MethodConversion(symbol => { return(symbol.Name == readFile ? methodConversion : MethodConversion.Unknown); }) .Callbacks(c => c.AfterAnalyzation(afterAnalyzationFn)) ) ); Assert.DoesNotThrowAsync(async() => await generator.GenerateAsync(config)); } }
public void ConfiguratedAwaitedFunctionTask() { var result3 = Task.Run(() => { SimpleFile.Read(); return(true); }).ConfigureAwait(false).GetAwaiter().GetResult(); }
public void WaitFunctionTaskNoResult() { Task.Run(() => { SimpleFile.Read(); return(true); }).Wait(); }
public void AwaitedFunctionTask() { var result2 = Task.Run(() => { SimpleFile.Read(); return(true); }).GetAwaiter().GetResult(); }
public void NotAwaitedFunctionTask() { Task.Run(() => { SimpleFile.Read(); return(true); }); }
public void WaitFunctionTask() { var result = Task.Run(() => { SimpleFile.Read(); return(true); }).Result; }
public void Test() { Execute(val => { SimpleFile.Read(); SimpleFile.Read(); }); }
public Task NoCastReturnTask() { return(Task.Run(() => { SimpleFile.Read(); return true; })); }
public void PreconditionVoid(string name) { if (name == null) { throw new ArgumentNullException(nameof(name)); } SimpleFile.Read(); }
public void Test2() { #if ASYNC SimpleFile.Read(); #else SimpleFile.Read(); #endif }
public void Test() { Assert.DoesNotThrow(() => { SimpleFile.Clear(); SimpleFile.Read(); }); }
public void ReadFile(string path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } SimpleFile.Read(); }
public IEnumerable <int> GetInts(bool value) { if (!value) { yield break; } SimpleFile.Read(); }
public void Test() { SimpleFile.Read(); Action action = () => { SimpleFile.Read(); }; }
public void Test() { #if TEST SimpleFile.Read(); #else SimpleFile.Read(); #endif }
public void Test(GenericTypeParameter <bool> test) { test.Execute(() => { SimpleFile.Read(); return(true); }); }
public void Test2() { Task.Run(() => { SimpleFile.Read(); return(true); }); }