예제 #1
0
        protected override IMetadataScope GetFixedPlatformVersion(AssemblyNameReference assyName)
        {
            var baseResult = base.GetFixedPlatformVersion(assyName);

            if (baseResult is AssemblyNameReference refName)
            {
                assyName = refName;
            }
            var sameRef = _repack.TargetAssemblyMainModule.AssemblyReferences.FirstOrDefault(a => a.Name == assyName.Name);

            if (sameRef != null && sameRef.Version > assyName.Version)
            {
                var ret = _repack.MergeScope(sameRef);
                return(ret);
            }

            return(baseResult);
        }
예제 #2
0
        public void PostRepackReferences()
        {
            if (!enabled)
            {
                return;
            }

            IMetadataScope ikvmRuntimeReference = repack.TargetAssemblyMainModule.AssemblyReferences.FirstOrDefault(r => r.Name == "IKVM.Runtime");

            if (ikvmRuntimeReference == null)
            {
                ikvmRuntimeReference = repack.MergeScope(repack.GlobalAssemblyResolver.Resolve(new AssemblyNameReference("IKVM.Runtime", new Version())).Name);
            }
            if (ikvmRuntimeReference == null)
            {
                enabled = false;
            }
            else
            {
                sourceFileAttributeTypeReference = new TypeReference("IKVM.Attributes", "SourceFileAttribute", TargetAssemblyMainModule, ikvmRuntimeReference);
                sourceFileAttributeConstructor   = new MethodReference(".ctor", TargetAssemblyMainModule.TypeSystem.Void, sourceFileAttributeTypeReference)
                {
                    HasThis = true, Parameters = { new ParameterDefinition(TargetAssemblyMainModule.TypeSystem.String) }
                };

                lineNumberTableAttributeTypeReference = new TypeReference("IKVM.Attributes", "LineNumberTableAttribute", TargetAssemblyMainModule, ikvmRuntimeReference);
                lineNumberTableAttributeConstructor1  = new MethodReference(".ctor", TargetAssemblyMainModule.TypeSystem.Void, lineNumberTableAttributeTypeReference)
                {
                    HasThis = true, Parameters = { new ParameterDefinition(TargetAssemblyMainModule.TypeSystem.UInt16) }
                };
                lineNumberTableAttributeConstructor2 = new MethodReference(".ctor", TargetAssemblyMainModule.TypeSystem.Void, lineNumberTableAttributeTypeReference)
                {
                    HasThis = true, Parameters = { new ParameterDefinition(new ArrayType(TargetAssemblyMainModule.TypeSystem.Byte)) }
                };
            }
        }
예제 #3
0
 public IMetadataScope FixPlatformVersion(AssemblyNameReference assyName)
 {
     return(GetFixedPlatformVersion(assyName) ?? repack.MergeScope(assyName));
 }
예제 #4
0
        private TypeReference CreateReference(ExportedType type)
        {
            _repackContext.PlatformFixer.FixPlatformVersion(type);

            return new TypeReference(type.Namespace, type.Name, _repackContext.TargetAssemblyMainModule, _repackContext.MergeScope(type.Scope))
            {
                DeclaringType = type.DeclaringType != null ? CreateReference(type.DeclaringType) : null,
            };
        }
예제 #5
0
 private TypeReference CreateReference(ExportedType type)
 {
     return(new TypeReference(type.Namespace, type.Name, _repackContext.TargetAssemblyMainModule, _repackContext.MergeScope(type.Scope))
     {
         DeclaringType = type.DeclaringType != null?CreateReference(type.DeclaringType) : null,
     });
 }