Guo Hui 6 éve
szülő
commit
c0abc5c24f

+ 2 - 4
src/Chino.Kernel/Chino.Kernel.csproj

@@ -3,14 +3,12 @@
   <PropertyGroup>
     <OutputType>Library</OutputType>
     <TargetFramework>netcoreapp3.0</TargetFramework>
-    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
-    <RuntimeMetadataVersion>v4.0.30319</RuntimeMetadataVersion>
-    <DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
     <OutputPath>$(SolutionDir)../out/bin/</OutputPath>
+    <RootNamespace>Chino</RootNamespace>
   </PropertyGroup>
 
   <ItemGroup>
-    <ProjectReference Include="..\System.Private.CorLib\System.Private.CorLib.csproj" />
+    <PackageReference Include="BitFields" Version="0.1.0" />
   </ItemGroup>
 
 </Project>

+ 13 - 0
src/Chino.Kernel/Devices/Serial/Uart.cs

@@ -0,0 +1,13 @@
+using System;
+
+namespace Chino.Devices.Serial
+{
+    public class Uart
+    {
+    }
+
+    public partial struct Uart0Reg
+    {
+        enum BitFields { A = 1 }
+    }
+}

+ 17 - 0
src/Chino.Kernel/Devices/Serial/Uart0Reg.BitFields.cs

@@ -0,0 +1,17 @@
+using BitFields;
+
+namespace Chino.Devices.Serial
+{
+    partial struct Uart0Reg
+    {
+        public volatile byte Value;
+
+        private const int AShift = 0;
+        private const byte AMask = unchecked((byte)((1U << 1) - (1U << 0)));
+        public Bit1 A
+        {
+            get => (Bit1)((Value & AMask) >> AShift);
+            set => Value = unchecked((byte)((Value & ~AMask) | ((((byte)value) << AShift) & AMask)));
+        }
+    }
+}

+ 8 - 0
src/Chino.Kernel/Threading/ThreadManager.cs

@@ -0,0 +1,8 @@
+using System;
+
+namespace Chino.Threading
+{
+    public class ThreadManager
+    {
+    }
+}

+ 2 - 1
src/Native/CMakeLists.txt

@@ -7,7 +7,8 @@ set(SRCS natsu.fcall.cpp
          natsu.gc.cpp
          main.cpp
          Generated/System.Private.CorLib.cpp
-         Generated/Chino.Kernel.cpp)
+         Generated/Chino.Kernel.cpp
+         Generated/BitFields.cpp)
          
 if (NOT WIN32)
     set(ASM_SRCS crt.S)

+ 1 - 0
src/Native/natsu.fcall.cpp

@@ -1,5 +1,6 @@
 #include "Chino.Kernel.h"
 #include "System.Private.CorLib.h"
+#include <cstring>
 
 #ifdef WIN32
 #include <Windows.h>

+ 1 - 1
src/Native/natsu.runtime.cpp

@@ -32,4 +32,4 @@ std::u16string_view to_string_view(gc_obj_ref<::System_Private_CorLib::System::S
         return {};
     return { reinterpret_cast<const char16_t *>(&string->_firstChar), (size_t)string->_stringLength };
 }
-} // namespace  natsu
+} // namespace natsu

+ 17 - 15
src/Native/natsu.runtime.h

@@ -276,6 +276,12 @@ struct gc_ref
     }
 };
 
+template <class T>
+gc_ref<T> gc_ref_from_ref(T &ref)
+{
+    return gc_ref<T>(ref);
+}
+
 template <class T>
 struct gc_ptr
 {
@@ -349,7 +355,7 @@ struct gc_ptr<void>
 
     template <class U>
     gc_ptr(const gc_ptr<U> &other) noexcept
-        : ptr_(reinterpret_cast<T *>(other.ptr_))
+        : ptr_(reinterpret_cast<void *>(other.ptr_))
     {
     }
 
@@ -440,7 +446,7 @@ struct gc_obj_ref
     }
 
     template <class U>
-    gc_ref<U> &unbox()
+    gc_ref<U> unbox()
     {
         auto value = dynamic_cast<U *>(ptr_);
         assert(value);
@@ -512,12 +518,6 @@ gc_ref<T> gc_ref_from_this(T *_this)
     return gc_ref<T>(*_this);
 }
 
-template <class T>
-gc_ref<T> gc_ref_from_ref(T &ref)
-{
-    return gc_ref<T>(ref);
-}
-
 template <class T>
 natsu_exception make_exception(gc_obj_ref<T> exception)
 {
@@ -566,13 +566,15 @@ gc_obj_ref<::System_Private_CorLib::System::String> load_string(std::u16string_v
 std::u16string_view to_string_view(gc_obj_ref<::System_Private_CorLib::System::String> string);
 }
 
-#define NATSU_PRIMITIVE_IMPL_BYTE \
-    Byte() = default;             \
-    Byte(uint8_t value) : m_value(value) {}
+#define NATSU_PRIMITIVE_IMPL_BYTE           \
+    Byte() = default;                       \
+    Byte(uint8_t value) : m_value(value) {} \
+    operator uint8_t() const noexcept { return m_value; }
 
-#define NATSU_PRIMITIVE_IMPL_SBYTE \
-    SByte() = default;             \
-    SByte(int8_t value) : m_value(value) {}
+#define NATSU_PRIMITIVE_IMPL_SBYTE          \
+    SByte() = default;                      \
+    SByte(int8_t value) : m_value(value) {} \
+    operator int8_t() const noexcept { return m_value; }
 
 #define NATSU_PRIMITIVE_IMPL_BOOLEAN                   \
     Boolean() = default;                               \
@@ -640,7 +642,7 @@ std::u16string_view to_string_view(gc_obj_ref<::System_Private_CorLib::System::S
         assert(index < header_.length_);                   \
         return elements_[index];                           \
     }                                                      \
-    ::natsu::gc_ref<T> &ref_at(int index)                  \
+    ::natsu::gc_ref<T> ref_at(int index)                   \
     {                                                      \
         assert(index < header_.length_);                   \
         return ::natsu::gc_ref_from_ref(elements_[index]); \

+ 161 - 27
src/Natsu.Compiler/Program.cs

@@ -14,7 +14,7 @@ namespace Natsu.Compiler
     {
         static void Main(string[] args)
         {
-            var fileName = @"..\..\..\..\..\out\bin\netcoreapp3.0\Chino.Kernel.dll";
+            var path = @"..\..\..\..\..\out\bin\netcoreapp3.0\Chino.Kernel.dll";
             var resolver = new AssemblyResolver();
             var modCtx = new ModuleContext(resolver);
             resolver.DefaultModuleContext = modCtx;
@@ -22,16 +22,25 @@ namespace Natsu.Compiler
             resolver.FindExactMatch = false;
             resolver.UseGAC = false;
             resolver.PreSearchPaths.Add(Path.GetFullPath(@"..\..\..\..\..\out\bin\netcoreapp3.0"));
+            resolver.PreSearchPaths.Add(Path.GetFullPath(@"C:\Users\sunny\.nuget\packages\bitfields\0.1.0\lib\netstandard1.0"));
 
-            var module = ModuleDefMD.Load(fileName);
+            var modules = new HashSet<ModuleDef>();
 
-            foreach (var ass in module.GetAssemblyRefs())
+            void AddAssemblies(ModuleDef module)
             {
-                var r = resolver.ResolveThrow(ass, module);
-                var generator = new Generator(r.Modules[0]);
-                generator.Generate();
+                modules.Add(module);
+
+                foreach (var ass in module.GetAssemblyRefs())
+                {
+                    var r = resolver.ResolveThrow(ass, module);
+                    foreach (var m in r.Modules)
+                        AddAssemblies(m);
+                }
             }
 
+            AddAssemblies(ModuleDefMD.Load(path));
+
+            foreach (var module in modules)
             {
                 var generator = new Generator(module);
                 generator.Generate();
@@ -59,8 +68,6 @@ namespace Natsu.Compiler
             {
                 var typeDesc = new TypeDesc(type);
                 _typeDescs.Add(type, typeDesc);
-                if (type.NestedTypes.Count != 0)
-                    throw new NotImplementedException();
 
                 if (type.FullName == "System.SZArray`1")
                     _szArrayType = typeDesc;
@@ -76,13 +83,21 @@ namespace Natsu.Compiler
                 writer.WriteLine("// Generated by natsu clr compiler.");
                 writer.WriteLine("#pragma once");
                 if (_module.Assembly.Name == "System.Private.CorLib")
+                {
                     writer.WriteLine("#include <natsu.runtime.h>");
+                }
                 else
-                    writer.WriteLine("#include <System.Private.CorLib.h>");
+                {
+                    foreach (var ass in _module.GetAssemblyRefs())
+                        writer.WriteLine($"#include <{ass.Name}.h>");
+                }
+
                 writer.WriteLine();
 
                 writer.WriteLine($"namespace {EscapeModuleName(_module)}");
                 writer.WriteLine("{");
+                WriteTypeForwards(writer);
+                writer.WriteLine();
                 WriteTypeForwardDeclares(writer);
                 writer.WriteLine();
                 WriteTypeDeclares(writer);
@@ -162,10 +177,7 @@ namespace Natsu.Compiler
             if (type.FullName == "System.ValueType")
                 return null;
             var baseType = type.BaseType;
-            if (baseType?.DefinitionAssembly.Name != "System.Private.CorLib")
-                return baseType?.ResolveTypeDefThrow();
-            else
-                return baseType;
+            return baseType;
         }
 
         private void AddTypeRef(TypeDesc declareDesc, TypeSig fieldType, bool force)
@@ -179,6 +191,7 @@ namespace Natsu.Compiler
                     case ElementType.Var:
                     case ElementType.ByRef:
                     case ElementType.Ptr:
+                    case ElementType.CModReqd:
                         break;
                     case ElementType.Boolean:
                     case ElementType.Char:
@@ -220,15 +233,57 @@ namespace Natsu.Compiler
         {
             if (typeDef != null && (force || typeDef.IsValueType))
             {
-                var targetDesc = _typeDescs[typeDef];
-                if (declareDesc != targetDesc)
+                if (_typeDescs.TryGetValue(typeDef, out var targetDesc))
                 {
-                    declareDesc.UsedTypes.Add(targetDesc);
-                    targetDesc.UsedByTypes.Add(declareDesc);
+                    if (declareDesc != targetDesc)
+                    {
+                        declareDesc.UsedTypes.Add(targetDesc);
+                        targetDesc.UsedByTypes.Add(declareDesc);
+                    }
                 }
             }
         }
 
+        private void WriteTypeForwards(StreamWriter writer)
+        {
+            var types = _module.ExportedTypes.Where(x => x.Attributes == TypeAttributes.Forwarder).ToList();
+            var index = 0;
+            foreach (var type in types)
+            {
+                WriteTypeForward(writer, 0, type);
+                if (index++ != types.Count - 1)
+                    writer.WriteLine();
+            }
+
+            if (types.Any())
+                writer.WriteLine();
+        }
+
+        private void WriteTypeForward(StreamWriter writer, int ident, dnlib.DotNet.ExportedType type)
+        {
+            var nss = type.Namespace.Split('.', StringSplitOptions.RemoveEmptyEntries)
+                .Select(EscapeNamespaceName).ToList();
+
+            writer.Ident(ident);
+            foreach (var ns in nss)
+                writer.Write($"namespace {ns} {{ ");
+
+            if (type.ContainsGenericParameter)
+                throw new NotImplementedException();
+
+            //if (type.HasGenericParameters)
+            //{
+            //    var typeNames = type.TypeDef.GenericParameters.Select(x => "class " + x.Name.String).ToList();
+            //    writer.Ident(ident).Write($"template <{string.Join(", ", typeNames)}> ");
+            //}
+
+            var fowardName = "::" + EscapeModuleName(type.Implementation.Name) + "::" + EscapeTypeName(type.ToTypeRef(), true, false);
+            writer.Ident(ident).Write($"using {type.Name} = {fowardName};");
+
+            foreach (var ns in nss)
+                writer.Write(" }");
+        }
+
         #region Forward Declares
         private void WriteTypeForwardDeclares(StreamWriter writer)
         {
@@ -348,10 +403,10 @@ namespace Natsu.Compiler
             writer.WriteLine();
         }
 
-        private string EscapeTypeName(ITypeDefOrRef type, bool isBaseType, bool hasModuleName)
+        private string EscapeTypeName(ITypeDefOrRef type, TypeDefOrRefSig sig, bool isBaseType, bool hasModuleName)
         {
             var sb = new StringBuilder();
-            if (!isBaseType && !type.IsValueType)
+            if (!isBaseType && !sig.IsValueType)
                 sb.Append("::natsu::gc_obj_ref<");
 
             if (hasModuleName)
@@ -376,6 +431,43 @@ namespace Natsu.Compiler
                 sb.Append(">");
             }
 
+            if (!isBaseType && !sig.IsValueType)
+                sb.Append(">");
+
+            return sb.ToString();
+        }
+
+        private string EscapeTypeName(ITypeDefOrRef type, bool isBaseType, bool hasModuleName)
+        {
+            if (type is TypeSpec typeSpec)
+            {
+                return EscapeTypeName(typeSpec.TypeSig, null, isBaseType);
+            }
+
+            var sb = new StringBuilder();
+            if (!isBaseType && !type.IsValueType)
+                sb.Append("::natsu::gc_obj_ref<");
+
+            if (hasModuleName)
+                sb.Append("::" + EscapeModuleName(type.DefinitionAssembly) + "::");
+            var nss = type.Namespace.Split('.', StringSplitOptions.RemoveEmptyEntries)
+                .Select(EscapeNamespaceName).ToList();
+            foreach (var ns in nss)
+                sb.Append($"{ns}::");
+            sb.Append(EscapeTypeName(type.Name));
+            if (false && type.NumberOfGenericParameters != 0)
+            {
+                sb.Append("<");
+                if (type is TypeDef typeDef)
+                {
+                    sb.Append(string.Join(", ", typeDef.GenericParameters.Select(x => x.Name)));
+                }
+                else
+                    throw new NotImplementedException();
+
+                sb.Append(">");
+            }
+
             if (!isBaseType && !type.IsValueType)
                 sb.Append(">");
 
@@ -422,14 +514,14 @@ namespace Natsu.Compiler
             writer.WriteLine($"){surfix};");
         }
 
-        private string EscapeTypeName(TypeSig fieldType, TypeDef declaringType = null)
+        private string EscapeTypeName(TypeSig fieldType, TypeDef declaringType = null, bool isBaseType = false)
         {
             var sb = new StringBuilder();
-            EscapeTypeName(sb, fieldType, declaringType);
+            EscapeTypeName(sb, fieldType, declaringType, isBaseType);
             return sb.ToString();
         }
 
-        private void EscapeTypeName(StringBuilder sb, TypeSig cntSig, TypeDef declaringType = null)
+        private void EscapeTypeName(StringBuilder sb, TypeSig cntSig, TypeDef declaringType = null, bool isBaseType = false)
         {
             switch (cntSig.ElementType)
             {
@@ -458,7 +550,7 @@ namespace Natsu.Compiler
                                 if (sig.TypeDef == declaringType)
                                     sb.Append(GetConstantTypeName(cntSig.ElementType));
                                 else
-                                    sb.Append(EscapeTypeName(sig.TypeDefOrRef, isBaseType: false, hasModuleName: true));
+                                    sb.Append(EscapeTypeName(sig.TypeDefOrRef, sig, isBaseType: isBaseType, hasModuleName: true));
                                 break;
                             default:
                                 throw new NotSupportedException();
@@ -472,10 +564,10 @@ namespace Natsu.Compiler
                         switch (cntSig)
                         {
                             case TypeDefOrRefSig sig:
-                                if (sig.IsValueType && sig.TypeDef == declaringType)
+                                if (sig.IsValueType && declaringType != null && sig.TypeDef == declaringType)
                                     sb.Append(GetConstantTypeName(cntSig.ElementType));
                                 else
-                                    sb.Append(EscapeTypeName(sig.TypeDefOrRef, isBaseType: false, hasModuleName: true));
+                                    sb.Append(EscapeTypeName(sig.TypeDefOrRef, sig, isBaseType: isBaseType, hasModuleName: true));
                                 break;
                             default:
                                 throw new NotSupportedException();
@@ -517,6 +609,9 @@ namespace Natsu.Compiler
                 case ElementType.Pinned:
                     EscapeTypeName(sb, cntSig.Next, declaringType);
                     break;
+                case ElementType.CModReqd:
+                    EscapeTypeName(sb, cntSig.Next, declaringType);
+                    break;
                 default:
                     throw new NotSupportedException();
             }
@@ -796,7 +891,7 @@ namespace Natsu.Compiler
             {
                 var target = stack.Pop();
                 string expr = target.expression + (IsTargetValueType(target.type) ? "." : "->") + EscapeIdentifier(field.Name);
-                stack.Push(new ByRefSig(field.FieldSig.Type), expr);
+                stack.Push(new ByRefSig(field.FieldSig.Type), $"::natsu::gc_ref_from_ref({expr})");
             }
 
             void ConvertStfld(IField field)
@@ -864,6 +959,11 @@ namespace Natsu.Compiler
                 stack.Push(local.Type, $"_l{local.Index}");
             }
 
+            void ConvertLdloc_a(Local local)
+            {
+                stack.Push(new ByRefSig(local.Type), $"::natsu::gc_ref_from_ref(_l{local.Index})");
+            }
+
             void ConvertStloc_I(int index)
             {
                 ConvertStloc(method.Body.Variables[index]);
@@ -1058,10 +1158,16 @@ namespace Natsu.Compiler
                 stack.Push(_corLibTypes.UIntPtr, $"static_cast<uintptr_t>({PointerToU(v1)})");
             }
 
+            void ConvertConv_U1()
+            {
+                var v1 = stack.Pop();
+                stack.Push(_corLibTypes.Byte, $"static_cast<uint8_t>({PointerToU(v1)})");
+            }
+
             void ConvertConv_U8()
             {
                 var v1 = stack.Pop();
-                stack.Push(_corLibTypes.Byte, $"static_cast<uint64_t>({PointerToU(v1)})");
+                stack.Push(_corLibTypes.UInt64, $"static_cast<uint64_t>({PointerToU(v1)})");
             }
 
             string PointerToU((TypeSig type, string expression) src)
@@ -1174,6 +1280,20 @@ namespace Natsu.Compiler
                 stack.Push(v1.type, $"{v1.expression} ^ {v2.expression}");
             }
 
+            void ConvertAnd()
+            {
+                var v2 = stack.Pop();
+                var v1 = stack.Pop();
+                stack.Push(v1.type, $"{v1.expression} & {v2.expression}");
+            }
+
+            void ConvertOr()
+            {
+                var v2 = stack.Pop();
+                var v1 = stack.Pop();
+                stack.Push(v1.type, $"{v1.expression} | {v2.expression}");
+            }
+
             void ConvertMul()
             {
                 var v2 = stack.Pop();
@@ -1291,6 +1411,9 @@ namespace Natsu.Compiler
                 case Code.Ldloc_S:
                     ConvertLdloc((Local)op.Operand);
                     break;
+                case Code.Ldloca_S:
+                    ConvertLdloc_a((Local)op.Operand);
+                    break;
                 case Code.Stloc_0:
                     ConvertStloc_I(0);
                     break;
@@ -1354,6 +1477,9 @@ namespace Natsu.Compiler
                 case Code.Conv_U:
                     ConvertConv_U();
                     break;
+                case Code.Conv_U1:
+                    ConvertConv_U1();
+                    break;
                 case Code.Conv_U8:
                     ConvertConv_U8();
                     break;
@@ -1411,12 +1537,20 @@ namespace Natsu.Compiler
                 case Code.Xor:
                     ConvertXor();
                     break;
+                case Code.And:
+                    ConvertAnd();
+                    break;
+                case Code.Or:
+                    ConvertOr();
+                    break;
                 case Code.Mul:
                     ConvertMul();
                     break;
                 case Code.Throw:
                     ConvertThrow();
                     break;
+                case Code.Volatile:
+                    break;
                 default:
                     throw new NotSupportedException(op.ToString());
             }

+ 10 - 2
src/Natsu.sln

@@ -5,14 +5,18 @@ VisualStudioVersion = 16.0.29021.104
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Natsu.Compiler", "Natsu.Compiler\Natsu.Compiler.csproj", "{AC6248DB-5117-4C47-A3E7-D0B7E6258F6B}"
 	ProjectSection(ProjectDependencies) = postProject
+		{A4CE4A60-2E56-4712-901B-8E5FA1354FD6} = {A4CE4A60-2E56-4712-901B-8E5FA1354FD6}
 		{7374FA7F-5B76-40C8-8F8F-EB9CA53A8C2F} = {7374FA7F-5B76-40C8-8F8F-EB9CA53A8C2F}
+		{2C03C9E9-3EE6-4F74-8BF7-C9040E9E4A14} = {2C03C9E9-3EE6-4F74-8BF7-C9040E9E4A14}
 	EndProjectSection
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.CorLib", "System.Private.CorLib\System.Private.CorLib.csproj", "{CE15C733-B010-41FD-B1B6-D0D4327F0653}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chino.Kernel", "Chino.Kernel\Chino.Kernel.csproj", "{7374FA7F-5B76-40C8-8F8F-EB9CA53A8C2F}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Chino.Kernel", "Chino.Kernel\Chino.Kernel.csproj", "{7374FA7F-5B76-40C8-8F8F-EB9CA53A8C2F}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Runtime", "System.Runtime\System.Runtime.csproj", "{A4CE4A60-2E56-4712-901B-8E5FA1354FD6}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime", "System.Runtime\System.Runtime.csproj", "{A4CE4A60-2E56-4712-901B-8E5FA1354FD6}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Diagnostics.Debug", "System.Diagnostics.Debug\System.Diagnostics.Debug.csproj", "{2C03C9E9-3EE6-4F74-8BF7-C9040E9E4A14}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -36,6 +40,10 @@ Global
 		{A4CE4A60-2E56-4712-901B-8E5FA1354FD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{A4CE4A60-2E56-4712-901B-8E5FA1354FD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{A4CE4A60-2E56-4712-901B-8E5FA1354FD6}.Release|Any CPU.Build.0 = Release|Any CPU
+		{2C03C9E9-3EE6-4F74-8BF7-C9040E9E4A14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{2C03C9E9-3EE6-4F74-8BF7-C9040E9E4A14}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{2C03C9E9-3EE6-4F74-8BF7-C9040E9E4A14}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{2C03C9E9-3EE6-4F74-8BF7-C9040E9E4A14}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 16 - 0
src/System.Diagnostics.Debug/System.Diagnostics.Debug.csproj

@@ -0,0 +1,16 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp3.0</TargetFramework>
+    <DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
+    <OutputPath>$(SolutionDir)../out/bin/</OutputPath>
+    <SignAssembly>true</SignAssembly>
+    <AssemblyOriginatorKeyFile>$(SolutionDir)../tools/Open.snk</AssemblyOriginatorKeyFile>
+    <AssemblyVersion>4.2.1.0</AssemblyVersion>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\System.Private.CorLib\System.Private.CorLib.csproj" />
+  </ItemGroup>
+
+</Project>

+ 5 - 0
src/System.Diagnostics.Debug/TypeForwards.cs

@@ -0,0 +1,5 @@
+using System;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+
+[assembly: TypeForwardedTo(typeof(Debug))]

+ 18 - 0
src/System.Private.CorLib/Reflection/AssemblyCompanyAttribute.cs

@@ -0,0 +1,18 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Reflection
+{
+    [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
+    public sealed class AssemblyCompanyAttribute : Attribute
+    {
+        public AssemblyCompanyAttribute(string company)
+        {
+            Company = company;
+        }
+
+        public string Company { get; }
+    }
+}
+

+ 18 - 0
src/System.Private.CorLib/Reflection/AssemblyConfigurationAttribute.cs

@@ -0,0 +1,18 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Reflection
+{
+    [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
+    public sealed class AssemblyConfigurationAttribute : Attribute
+    {
+        public AssemblyConfigurationAttribute(string configuration)
+        {
+            Configuration = configuration;
+        }
+
+        public string Configuration { get; }
+    }
+}
+

+ 20 - 0
src/System.Private.CorLib/Reflection/AssemblyFileVersionAttribute.cs

@@ -0,0 +1,20 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Reflection
+{
+    [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
+    public sealed class AssemblyFileVersionAttribute : Attribute
+    {
+        public AssemblyFileVersionAttribute(string version)
+        {
+            if (version == null)
+                throw new ArgumentNullException(nameof(version));
+            Version = version;
+        }
+
+        public string Version { get; }
+    }
+}
+

+ 18 - 0
src/System.Private.CorLib/Reflection/AssemblyInformationalVersionAttribute.cs

@@ -0,0 +1,18 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Reflection
+{
+    [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
+    public sealed class AssemblyInformationalVersionAttribute : Attribute
+    {
+        public AssemblyInformationalVersionAttribute(string informationalVersion)
+        {
+            InformationalVersion = informationalVersion;
+        }
+
+        public string InformationalVersion { get; }
+    }
+}
+

+ 18 - 0
src/System.Private.CorLib/Reflection/AssemblyProductAttribute.cs

@@ -0,0 +1,18 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Reflection
+{
+    [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
+    public sealed class AssemblyProductAttribute : Attribute
+    {
+        public AssemblyProductAttribute(string product)
+        {
+            Product = product;
+        }
+
+        public string Product { get; }
+    }
+}
+

+ 18 - 0
src/System.Private.CorLib/Reflection/AssemblyTitleAttribute.cs

@@ -0,0 +1,18 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Reflection
+{
+    [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
+    public sealed class AssemblyTitleAttribute : Attribute
+    {
+        public AssemblyTitleAttribute(string title)
+        {
+            Title = title;
+        }
+
+        public string Title { get; }
+    }
+}
+

+ 18 - 0
src/System.Private.CorLib/Reflection/AssemblyVersionAttribute.cs

@@ -0,0 +1,18 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Reflection
+{
+    [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
+    public sealed class AssemblyVersionAttribute : Attribute
+    {
+        public AssemblyVersionAttribute(string version)
+        {
+            Version = version;
+        }
+
+        public string Version { get; }
+    }
+}
+

+ 3 - 1
src/System.Private.CorLib/System.Private.CorLib.csproj

@@ -6,9 +6,11 @@
     <AssemblyName>System.Private.CorLib</AssemblyName>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <LangVersion>8.0</LangVersion>
-    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
     <RuntimeMetadataVersion>v4.0.30319</RuntimeMetadataVersion>
     <DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
+    <SignAssembly>true</SignAssembly>
+    <AssemblyOriginatorKeyFile>$(SolutionDir)../tools/Open.snk</AssemblyOriginatorKeyFile>
+    <AssemblyVersion>4.2.1.0</AssemblyVersion>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
     <NoWarn>1701;1702;0169</NoWarn>

+ 3 - 2
src/System.Runtime/System.Runtime.csproj

@@ -2,10 +2,11 @@
 
   <PropertyGroup>
     <TargetFramework>netcoreapp3.0</TargetFramework>
-    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
-    <RuntimeMetadataVersion>v4.0.30319</RuntimeMetadataVersion>
     <DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
     <OutputPath>$(SolutionDir)../out/bin/</OutputPath>
+    <SignAssembly>true</SignAssembly>
+    <AssemblyOriginatorKeyFile>$(SolutionDir)../tools/Open.snk</AssemblyOriginatorKeyFile>
+    <AssemblyVersion>4.2.1.0</AssemblyVersion>
   </PropertyGroup>
 
   <ItemGroup>

+ 14 - 0
src/System.Runtime/TypeForwards.cs

@@ -2,3 +2,17 @@
 using System.Runtime.CompilerServices;
 
 [assembly: TypeForwardedTo(typeof(Object))]
+[assembly: TypeForwardedTo(typeof(ValueType))]
+[assembly: TypeForwardedTo(typeof(Enum))]
+[assembly: TypeForwardedTo(typeof(SByte))]
+[assembly: TypeForwardedTo(typeof(Byte))]
+[assembly: TypeForwardedTo(typeof(Char))]
+[assembly: TypeForwardedTo(typeof(Int16))]
+[assembly: TypeForwardedTo(typeof(UInt16))]
+[assembly: TypeForwardedTo(typeof(Int32))]
+[assembly: TypeForwardedTo(typeof(UInt32))]
+[assembly: TypeForwardedTo(typeof(Int64))]
+[assembly: TypeForwardedTo(typeof(UInt64))]
+[assembly: TypeForwardedTo(typeof(IntPtr))]
+[assembly: TypeForwardedTo(typeof(UIntPtr))]
+[assembly: TypeForwardedTo(typeof(String))]

BIN
tools/Open.snk