{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/16211","repository_url":"https://api.github.com/repos/dotnet/roslyn","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/16211/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/16211/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/16211/events","html_url":"https://github.com/dotnet/roslyn/issues/16211","id":198565751,"number":16211,"title":"Can't reference mscorlib in .Net Core","user":{"login":"Pzixel","id":11201122,"avatar_url":"https://avatars3.githubusercontent.com/u/11201122?v=4","gravatar_id":"","url":"https://api.github.com/users/Pzixel","html_url":"https://github.com/Pzixel","followers_url":"https://api.github.com/users/Pzixel/followers","following_url":"https://api.github.com/users/Pzixel/following{/other_user}","gists_url":"https://api.github.com/users/Pzixel/gists{/gist_id}","starred_url":"https://api.github.com/users/Pzixel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pzixel/subscriptions","organizations_url":"https://api.github.com/users/Pzixel/orgs","repos_url":"https://api.github.com/users/Pzixel/repos","events_url":"https://api.github.com/users/Pzixel/events{/privacy}","received_events_url":"https://api.github.com/users/Pzixel/received_events","type":"User","site_admin":false},"labels":[{"id":166673288,"url":"https://api.github.com/repos/dotnet/roslyn/labels/Area-Compilers","name":"Area-Compilers","color":"5319e7","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2017-01-03T20:51:16Z","updated_at":"2018-03-14T16:36:30Z","closed_at":"2017-01-04T19:27:44Z","author_association":"NONE","body":"Here is sample code which is working on target `4.5.2`, but doesn't on `Core 1.0.1`. \r\n\r\n```csharp\r\nusing System;\r\nusing System.IO;\r\nusing System.Linq;\r\nusing System.Reflection;\r\nusing Microsoft.CodeAnalysis;\r\nusing Microsoft.CodeAnalysis.CSharp;\r\n\r\nclass Program\r\n{\r\n    static void Main(string[] args)\r\n    {\r\n        var greetings = HelloWorlder.GetGreetings();\r\n        // should write Hello World\r\n        greetings();\r\n    }\r\n}\r\n\r\npublic static class HelloWorlder\r\n{\r\n    public static Action GetGreetings()\r\n    {\r\n        var tree = CSharpSyntaxTree.ParseText(@\"\r\nusing System;\r\npublic class MyClass\r\n{\r\n    public static void Main()\r\n    {\r\n        Console.WriteLine(\"\"Hello World!\"\");\r\n        Console.ReadLine();\r\n    }   \r\n}\");\r\n        const string testAsmName = \"testLib\";\r\n\r\n        var coreDir = Path.GetDirectoryName(typeof(object).GetTypeInfo().Assembly.Location);\r\n\r\n        var mscorlib = MetadataReference.CreateFromFile(Path.Combine(coreDir, \"mscorlib.dll\"));\r\n        var compilation = CSharpCompilation.Create(testAsmName,\r\n            syntaxTrees: new[] { tree }, references: new[] { mscorlib });\r\n\r\n        var emitResult = compilation.Emit($\"{testAsmName}.dll\");\r\n\r\n        if (!emitResult.Success)\r\n        {\r\n            throw new Exception(string.Join(Environment.NewLine, emitResult.Diagnostics.Select((x, i) => $\"{i + 1}. {x}\")));\r\n        }\r\n        var ourAssembly = Assembly.Load(new AssemblyName(testAsmName));\r\n        var type = ourAssembly.GetType(\"MyClass\");\r\n\r\n        var meth = type.GetRuntimeMethod(\"Main\", Type.EmptyTypes);\r\n        return () => meth.Invoke(null, null);\r\n    }\r\n}\r\n```\r\nAs you can examine yourself, it writes `Hello world` on full framework but fails to compile on `.Net Core` with following errors:\r\n\r\n> 1. warning CS8021: No value for RuntimeMetadataVersion found. No assembly containing System.Object was found nor was a value for RuntimeMetadataVersion specified through options.\r\n> 2. (3,14): error CS0518: Predefined type 'System.Object' is not defined or imported\r\n> 3. (5,19): error CS0518: Predefined type 'System.Void' is not defined or imported\r\n> 4. (7,27): error CS0518: Predefined type 'System.String' is not defined or imported\r\n> 5. (7,9): error CS0518: Predefined type 'System.Object' is not defined or imported\r\n> 6. (7,9): error CS0103: The name 'Console' does not exist in the current context\r\n> 7. (8,9): error CS0518: Predefined type 'System.Object' is not defined or imported\r\n> 8. (8,9): error CS0103: The name 'Console' does not exist in the current context\r\n> 9. (3,14): error CS1729: 'object' does not contain a constructor that takes 0 arguments"},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/373088826","html_url":"https://github.com/dotnet/roslyn/issues/16211#issuecomment-373088826","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/16211","id":373088826,"user":{"login":"tmat","id":41759,"avatar_url":"https://avatars0.githubusercontent.com/u/41759?v=4","gravatar_id":"","url":"https://api.github.com/users/tmat","html_url":"https://github.com/tmat","followers_url":"https://api.github.com/users/tmat/followers","following_url":"https://api.github.com/users/tmat/following{/other_user}","gists_url":"https://api.github.com/users/tmat/gists{/gist_id}","starred_url":"https://api.github.com/users/tmat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmat/subscriptions","organizations_url":"https://api.github.com/users/tmat/orgs","repos_url":"https://api.github.com/users/tmat/repos","events_url":"https://api.github.com/users/tmat/events{/privacy}","received_events_url":"https://api.github.com/users/tmat/received_events","type":"User","site_admin":false},"created_at":"2018-03-14T16:36:30Z","updated_at":"2018-03-14T16:36:30Z","author_association":"MEMBER","body":"@terrajobst Please include me in the loop. "}}
{"actor":{"display_login":"tmat"}}