Closed zsoi closed 6 years ago
I got the same when trying to output Hello World
class C { public static void Main(string[] args) { System.Console.WriteLine("Hello World"); } }
This should now be fixed. I've stopped using C# Scripting which generated an assembly per each evaluation. I wrote an interpreter that interprets the tree without needing to compile.
I've put in
class C { public IEnumerator<int> Foo() { while(true) { yield return 1; } } }
and got
System.OutOfMemoryException: Insufficient memory to continue the execution of the program. at System.Runtime.InteropServices.Marshal.AllocHGlobal(IntPtr cb) at System.Runtime.InteropServices.Marshal.AllocHGlobal(Int32 cb) at System.Reflection.Internal.NativeHeapMemoryBlock.DisposableData..ctor(Int32 size) at System.Reflection.Internal.StreamMemoryBlockProvider.ReadMemoryBlockNoLock(Stream stream, Boolean isFileStream, Int64 start, Int32 size) at System.Reflection.PortableExecutable.PEReader..ctor(Stream peStream, PEStreamOptions options, Int32 size) at Microsoft.CodeAnalysis.ModuleMetadata.CreateFromStream(Stream peStream, PEStreamOptions options) at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(String path, MetadataReferenceProperties properties, DocumentationProvider documentation) at Microsoft.CodeAnalysis.Scripting.Hosting.RuntimeMetadataReferenceResolver.ResolveTrustedPlatformAssemblyCore(String name, MetadataReferenceProperties properties) at Microsoft.CodeAnalysis.Scripting.Hosting.RuntimeMetadataReferenceResolver.ResolveReference(String reference, String baseFilePath, MetadataReferenceProperties properties) at Microsoft.CodeAnalysis.Scripting.Script.GetReferencesForCompilation(CommonMessageProvider messageProvider, DiagnosticBag diagnostics, MetadataReference languageRuntimeReferenceOpt) at Microsoft.CodeAnalysis.CSharp.Scripting.CSharpScriptCompiler.CreateSubmission(Script script) at Microsoft.CodeAnalysis.Scripting.Script.GetCompilation() at Microsoft.CodeAnalysis.Scripting.Script
1.GetExecutor(CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Scripting.Script1.RunAsync(Object globals, Func
2 catchException, CancellationToken cancellationToken) at Quoter.Evaluate(String apiCallString, Boolean normalizeWhitespace) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 1042 at Quoter.AddModifyingCall(ApiCall apiCall, MethodCall methodCall) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 1018 at Quoter.AddModifyingCalls(Object treeElement, ApiCall apiCall, List1 values) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 1012 at Quoter.QuoteNode(SyntaxNode node, String name) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 182 at Quoter.QuotePropertyValue(SyntaxNode node, PropertyInfo property) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 259 at Quoter.<>c__DisplayClass28_0.<QuotePropertyValues>b__2(PropertyInfo propertyInfo) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 202 at System.Linq.Enumerable.WhereSelectArrayIterator
2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at System.Collections.Generic.List
1.AddEnumerable(IEnumerable1 enumerable) at System.Collections.Generic.List
1.InsertRange(Int32 index, IEnumerable1 collection) at Quoter.QuotePropertyValues(SyntaxNode node) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 199 at Quoter.QuoteNode(SyntaxNode node, String name) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 165 at Quoter.QuotePropertyValue(SyntaxNode node, PropertyInfo property) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 259 at Quoter.<>c__DisplayClass28_0.<QuotePropertyValues>b__2(PropertyInfo propertyInfo) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 202 at System.Linq.Enumerable.WhereSelectArrayIterator
2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at System.Collections.Generic.List
1.AddEnumerable(IEnumerable1 enumerable) at System.Collections.Generic.List
1.InsertRange(Int32 index, IEnumerable1 collection) at Quoter.QuotePropertyValues(SyntaxNode node) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 199 at Quoter.QuoteNode(SyntaxNode node, String name) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 165 at Quoter.Quote(Object treeElement, String name) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 157 at Quoter.<QuoteList>b__31_0(Object o) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 323 at System.Linq.Enumerable.SelectEnumerableIterator
2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at System.Collections.Generic.List
1.AddEnumerable(IEnumerable1 enumerable) at System.Collections.Generic.List
1..ctor(IEnumerable1 collection) at Quoter.QuoteList(IEnumerable syntaxList, String name) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 322 at Quoter.QuotePropertyValue(SyntaxNode node, PropertyInfo property) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 254 at Quoter.<>c__DisplayClass28_0.<QuotePropertyValues>b__2(PropertyInfo propertyInfo) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 202 at System.Linq.Enumerable.WhereSelectArrayIterator
2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at System.Collections.Generic.List
1.AddEnumerable(IEnumerable1 enumerable) at System.Collections.Generic.List
1.InsertRange(Int32 index, IEnumerable1 collection) at Quoter.QuotePropertyValues(SyntaxNode node) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 199 at Quoter.QuoteNode(SyntaxNode node, String name) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 165 at Quoter.Quote(Object treeElement, String name) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 157 at Quoter.<QuoteList>b__31_0(Object o) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 323 at System.Linq.Enumerable.SelectEnumerableIterator
2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at System.Collections.Generic.List
1.AddEnumerable(IEnumerable1 enumerable) at System.Collections.Generic.List
1..ctor(IEnumerable1 collection) at Quoter.QuoteList(IEnumerable syntaxList, String name) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 322 at Quoter.QuotePropertyValue(SyntaxNode node, PropertyInfo property) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 254 at Quoter.<>c__DisplayClass28_0.<QuotePropertyValues>b__2(PropertyInfo propertyInfo) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 202 at System.Linq.Enumerable.WhereSelectArrayIterator
2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at System.Collections.Generic.List
1.AddEnumerable(IEnumerable1 enumerable) at System.Collections.Generic.List
1.InsertRange(Int32 index, IEnumerable1 collection) at Quoter.QuotePropertyValues(SyntaxNode node) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 199 at Quoter.QuoteNode(SyntaxNode node, String name) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 165 at Quoter.Quote(Object treeElement, String name) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 157 at Quoter.Quote(SyntaxNode node) in C:\RoslynQuoter\src\Quoter\Quoter.cs:line 118 at QuoterService.Controllers.QuoterController.Get(String sourceText, NodeKind nodeKind, Boolean openCurlyOnNewLine, Boolean closeCurlyOnNewLine, Boolean preserveOriginalWhitespace, Boolean keepRedundantApiCalls, Boolean avoidUsingStatic) in C:\RoslynQuoter\src\Quoter.Web\Controllers\QuoterController.cs:line 38