diff --git a/.editorconfig b/.editorconfig index bedaa4a..dd3f821 100644 --- a/.editorconfig +++ b/.editorconfig @@ -65,7 +65,7 @@ dotnet_code_quality_unused_parameters = all:suggestion # var preferences csharp_style_var_elsewhere = false:silent -csharp_style_var_for_built_in_types = false:none +csharp_style_var_for_built_in_types = false:warning csharp_style_var_when_type_is_apparent = true:silent # Expression-bodied members diff --git a/Directory.Build.props b/Directory.Build.props index 6d5e254..b8d992d 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -37,12 +37,12 @@ enable - 3.0.0-preview9-19423-09 + 3.0.0 false - + diff --git a/Directory.Build.targets b/Directory.Build.targets index 4a17d77..341027f 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,13 +1,3 @@ - - - - - - - - - - diff --git a/TunnelVisionLabs.ReferenceAssemblyAnnotator/AnnotatorBuildTask.cs b/TunnelVisionLabs.ReferenceAssemblyAnnotator/AnnotatorBuildTask.cs index 36d3f68..5a05e6f 100644 --- a/TunnelVisionLabs.ReferenceAssemblyAnnotator/AnnotatorBuildTask.cs +++ b/TunnelVisionLabs.ReferenceAssemblyAnnotator/AnnotatorBuildTask.cs @@ -57,8 +57,8 @@ public ITaskItem[]? GeneratedAssemblies public override bool Execute() { - var unannotatedReferenceAssembly = TargetFrameworkDirectories.Select(path => Path.Combine(path.ItemSpec, UnannotatedReferenceAssembly + ".dll")).FirstOrDefault(File.Exists); - var annotatedReferenceAssembly = Path.Combine(AnnotatedReferenceAssemblyDirectory, UnannotatedReferenceAssembly + ".dll"); + string unannotatedReferenceAssembly = TargetFrameworkDirectories.Select(path => Path.Combine(path.ItemSpec, UnannotatedReferenceAssembly + ".dll")).FirstOrDefault(File.Exists); + string annotatedReferenceAssembly = Path.Combine(AnnotatedReferenceAssemblyDirectory, UnannotatedReferenceAssembly + ".dll"); bool foundAnnotatedAssembly = File.Exists(annotatedReferenceAssembly); Log.LogMessage($"Generating reference assembly for {UnannotatedReferenceAssembly}"); @@ -79,7 +79,7 @@ public override bool Execute() } Directory.CreateDirectory(OutputPath); - var outputAssembly = Path.Combine(OutputPath, Path.GetFileName(unannotatedReferenceAssembly)); + string outputAssembly = Path.Combine(OutputPath, Path.GetFileName(unannotatedReferenceAssembly)); Program.Main(Log, unannotatedReferenceAssembly, annotatedReferenceAssembly, outputAssembly); GeneratedAssemblies = new[] { new TaskItem(outputAssembly) }; diff --git a/TunnelVisionLabs.ReferenceAssemblyAnnotator/CustomAttributeFactory.cs b/TunnelVisionLabs.ReferenceAssemblyAnnotator/CustomAttributeFactory.cs index 7a4e700..c5a1771 100644 --- a/TunnelVisionLabs.ReferenceAssemblyAnnotator/CustomAttributeFactory.cs +++ b/TunnelVisionLabs.ReferenceAssemblyAnnotator/CustomAttributeFactory.cs @@ -76,5 +76,12 @@ public CustomAttribute AttributeUsage(AttributeTargets validOn, bool? allowMulti return customAttribute; } + + public CustomAttribute ReferenceAssembly() + { + MethodDefinition constructor = _wellKnownTypes.SystemRuntimeCompilerServicesReferenceAssemblyAttribute.Resolve().Methods.Single(method => method.IsConstructor && !method.IsStatic && method.Parameters.Count == 0); + var customAttribute = new CustomAttribute(_wellKnownTypes.Module.ImportReference(constructor)); + return customAttribute; + } } } diff --git a/TunnelVisionLabs.ReferenceAssemblyAnnotator/MethodFactory.cs b/TunnelVisionLabs.ReferenceAssemblyAnnotator/MethodFactory.cs index 8b7aa09..abcd6a0 100644 --- a/TunnelVisionLabs.ReferenceAssemblyAnnotator/MethodFactory.cs +++ b/TunnelVisionLabs.ReferenceAssemblyAnnotator/MethodFactory.cs @@ -8,12 +8,12 @@ namespace TunnelVisionLabs.ReferenceAssemblyAnnotator internal static class MethodFactory { - public static MethodDefinition DefaultConstructor(WellKnownTypes wellKnownTypes) - => Constructor(wellKnownTypes); + public static MethodDefinition DefaultConstructor(TypeSystem typeSystem) + => Constructor(typeSystem); - public static MethodDefinition Constructor(WellKnownTypes wellKnownTypes) + public static MethodDefinition Constructor(TypeSystem typeSystem) { - var constructor = new MethodDefinition(".ctor", MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName, wellKnownTypes.TypeSystem.Void); + var constructor = new MethodDefinition(".ctor", MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName, typeSystem.Void); constructor.Body = new MethodBody(constructor) { Instructions = diff --git a/TunnelVisionLabs.ReferenceAssemblyAnnotator/Program.cs b/TunnelVisionLabs.ReferenceAssemblyAnnotator/Program.cs index 41051b7..ceaf229 100644 --- a/TunnelVisionLabs.ReferenceAssemblyAnnotator/Program.cs +++ b/TunnelVisionLabs.ReferenceAssemblyAnnotator/Program.cs @@ -7,6 +7,7 @@ namespace TunnelVisionLabs.ReferenceAssemblyAnnotator using System.Collections.Generic; using System.IO; using System.Linq; + using System.Runtime.CompilerServices; using Microsoft.Build.Utilities; using Mono.Cecil; using Mono.Cecil.Rocks; @@ -19,11 +20,20 @@ internal static void Main(TaskLoggingHelper? log, string referenceAssembly, stri assemblyResolver.AddSearchDirectory(Path.GetDirectoryName(referenceAssembly)); using var assemblyDefinition = AssemblyDefinition.ReadAssembly(referenceAssembly, new ReaderParameters(ReadingMode.Immediate) { AssemblyResolver = assemblyResolver }); + foreach (var module in assemblyDefinition.Modules) + { + if (!module.Attributes.HasFlag(ModuleAttributes.ILOnly)) + { + log?.LogWarning(subcategory: null, "RA1000", helpKeyword: null, file: null, lineNumber: 0, columnNumber: 0, endLineNumber: 0, endColumnNumber: 0, "Skipping mixed-mode implementation assembly '{0}'", assemblyDefinition.Name); + return; + } + } + var annotatedAssemblyResolver = new DefaultAssemblyResolver(); annotatedAssemblyResolver.AddSearchDirectory(Path.GetDirectoryName(annotatedReferenceAssembly)); using var annotatedAssemblyDefinition = AssemblyDefinition.ReadAssembly(annotatedReferenceAssembly, new ReaderParameters(ReadingMode.Immediate) { AssemblyResolver = annotatedAssemblyResolver }); - var wellKnownTypes = new WellKnownTypes(assemblyDefinition.MainModule); + var wellKnownTypes = new WellKnownTypes(assemblyDefinition, DefineReferenceAssemblyAttribute); // Define embedded types used by the compiler var embeddedAttribute = DefineEmbeddedAttribute(assemblyDefinition, wellKnownTypes); @@ -44,6 +54,9 @@ internal static void Main(TaskLoggingHelper? log, string referenceAssembly, stri var notNullIfNotNullAttribute = DefineNotNullIfNotNullAttribute(assemblyDefinition, wellKnownTypes, attributeFactory); var notNullWhenAttribute = DefineNotNullWhenAttribute(assemblyDefinition, wellKnownTypes, attributeFactory); + // Ensure the assembly is marked with ReferenceAssemblyAttribute + EnsureReferenceAssemblyAttribute(assemblyDefinition, attributeFactory); + var attributesOfInterest = new Dictionary(); attributesOfInterest.Add(nullableAttribute.FullName, nullableAttribute); attributesOfInterest.Add(nullableContextAttribute.FullName, nullableContextAttribute); @@ -93,8 +106,18 @@ private static void AnnotateType(TaskLoggingHelper? log, TypeDefinition typeDefi } Annotate(typeDefinition, annotatedTypeDefinition, attributesOfInterest); + for (int i = 0; i < typeDefinition.Interfaces.Count; i++) + { + for (int j = 0; j < annotatedTypeDefinition.Interfaces.Count; j++) + { + if (EquivalenceComparers.TypeReference.Equals(typeDefinition.Interfaces[i].InterfaceType, annotatedTypeDefinition.Interfaces[j].InterfaceType)) + { + Annotate(typeDefinition.Interfaces[i], annotatedTypeDefinition.Interfaces[j], attributesOfInterest); + } + } + } - for (var i = 0; i < typeDefinition.GenericParameters.Count; i++) + for (int i = 0; i < typeDefinition.GenericParameters.Count; i++) { Annotate(typeDefinition.GenericParameters[i], annotatedTypeDefinition.GenericParameters[i], attributesOfInterest); } @@ -171,7 +194,7 @@ private static void Annotate(ICustomAttributeProvider provider, ICustomAttribute continue; var newCustomAttribute = new CustomAttribute(constructor); - for (var i = 0; i < customAttribute.ConstructorArguments.Count; i++) + for (int i = 0; i < customAttribute.ConstructorArguments.Count; i++) { newCustomAttribute.ConstructorArguments.Add(new CustomAttributeArgument(constructor.Parameters[i].ParameterType, customAttribute.ConstructorArguments[i].Value)); } @@ -269,7 +292,7 @@ private static TypeDefinition DefineEmbeddedAttribute(AssemblyDefinition assembl TypeAttributes.NotPublic | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, wellKnownTypes.Module.ImportReference(wellKnownTypes.SystemAttribute)); - var constructor = attribute.AddDefaultConstructor(wellKnownTypes); + var constructor = attribute.AddDefaultConstructor(wellKnownTypes.TypeSystem); MethodDefinition compilerGeneratedConstructor = wellKnownTypes.SystemRuntimeCompilerServicesCompilerGeneratedAttribute.Resolve().Methods.Single(method => method.IsConstructor && !method.IsStatic && method.Parameters.Count == 0); var customAttribute = new CustomAttribute(wellKnownTypes.Module.ImportReference(compilerGeneratedConstructor)); @@ -281,6 +304,25 @@ private static TypeDefinition DefineEmbeddedAttribute(AssemblyDefinition assembl return attribute; } + private static TypeDefinition DefineReferenceAssemblyAttribute(AssemblyDefinition assemblyDefinition, (TypeReference systemAttribute, TypeReference systemRuntimeCompilerServicesCompilerGeneratedAttribute) wellKnownTypes) + { + var attribute = new TypeDefinition( + @namespace: "System.Runtime.CompilerServices", + name: "ReferenceAssemblyAttribute", + TypeAttributes.NotPublic | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, + assemblyDefinition.MainModule.ImportReference(wellKnownTypes.systemAttribute)); + + attribute.AddDefaultConstructor(assemblyDefinition.MainModule.TypeSystem); + + MethodDefinition compilerGeneratedConstructor = wellKnownTypes.systemRuntimeCompilerServicesCompilerGeneratedAttribute.Resolve().Methods.Single(method => method.IsConstructor && !method.IsStatic && method.Parameters.Count == 0); + var customAttribute = new CustomAttribute(assemblyDefinition.MainModule.ImportReference(compilerGeneratedConstructor)); + attribute.CustomAttributes.Add(customAttribute); + + assemblyDefinition.MainModule.Types.Add(attribute); + + return attribute; + } + private static TypeDefinition DefineNullableAttribute(AssemblyDefinition assemblyDefinition, TypeReference embeddedAttribute, WellKnownTypes wellKnownTypes) { var attribute = new TypeDefinition( @@ -293,10 +335,10 @@ private static TypeDefinition DefineNullableAttribute(AssemblyDefinition assembl attribute.CustomAttributes.Add(new CustomAttribute(wellKnownTypes.Module.ImportReference(compilerGeneratedConstructor))); attribute.CustomAttributes.Add(new CustomAttribute(embeddedAttribute.Resolve().Methods.Single(method => method.IsConstructor && !method.IsStatic && method.Parameters.Count == 0))); - var constructorByte = MethodFactory.Constructor(wellKnownTypes); + var constructorByte = MethodFactory.Constructor(wellKnownTypes.TypeSystem); constructorByte.Parameters.Add(new ParameterDefinition(wellKnownTypes.TypeSystem.Byte)); - var constructorByteArray = MethodFactory.Constructor(wellKnownTypes); + var constructorByteArray = MethodFactory.Constructor(wellKnownTypes.TypeSystem); constructorByteArray.Parameters.Add(new ParameterDefinition(new ArrayType(wellKnownTypes.TypeSystem.Byte))); attribute.Methods.Add(constructorByte); @@ -319,7 +361,7 @@ private static TypeDefinition DefineNullableContextAttribute(AssemblyDefinition attribute.CustomAttributes.Add(new CustomAttribute(wellKnownTypes.Module.ImportReference(compilerGeneratedConstructor))); attribute.CustomAttributes.Add(new CustomAttribute(embeddedAttribute.Resolve().Methods.Single(method => method.IsConstructor && !method.IsStatic && method.Parameters.Count == 0))); - var constructor = MethodFactory.Constructor(wellKnownTypes); + var constructor = MethodFactory.Constructor(wellKnownTypes.TypeSystem); constructor.Parameters.Add(new ParameterDefinition(wellKnownTypes.TypeSystem.Byte)); attribute.Methods.Add(constructor); @@ -340,7 +382,7 @@ private static TypeDefinition DefineNullablePublicOnlyAttribute(AssemblyDefiniti attribute.CustomAttributes.Add(new CustomAttribute(wellKnownTypes.Module.ImportReference(compilerGeneratedConstructor))); attribute.CustomAttributes.Add(new CustomAttribute(embeddedAttribute.Resolve().Methods.Single(method => method.IsConstructor && !method.IsStatic && method.Parameters.Count == 0))); - var constructor = MethodFactory.Constructor(wellKnownTypes); + var constructor = MethodFactory.Constructor(wellKnownTypes.TypeSystem); constructor.Parameters.Add(new ParameterDefinition(wellKnownTypes.TypeSystem.Boolean)); attribute.Methods.Add(constructor); @@ -357,7 +399,7 @@ private static TypeDefinition DefineAllowNullAttribute(AssemblyDefinition assemb TypeAttributes.NotPublic | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, wellKnownTypes.Module.ImportReference(wellKnownTypes.SystemAttribute)); - attribute.AddDefaultConstructor(wellKnownTypes); + attribute.AddDefaultConstructor(wellKnownTypes.TypeSystem); attribute.CustomAttributes.Add(attributeFactory.AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property, inherited: false)); assemblyDefinition.MainModule.Types.Add(attribute); @@ -373,7 +415,7 @@ private static TypeDefinition DefineDisallowNullAttribute(AssemblyDefinition ass TypeAttributes.NotPublic | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, wellKnownTypes.Module.ImportReference(wellKnownTypes.SystemAttribute)); - attribute.AddDefaultConstructor(wellKnownTypes); + attribute.AddDefaultConstructor(wellKnownTypes.TypeSystem); attribute.CustomAttributes.Add(attributeFactory.AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property, inherited: false)); assemblyDefinition.MainModule.Types.Add(attribute); @@ -389,7 +431,7 @@ private static TypeDefinition DefineDoesNotReturnAttribute(AssemblyDefinition as TypeAttributes.NotPublic | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, wellKnownTypes.Module.ImportReference(wellKnownTypes.SystemAttribute)); - attribute.AddDefaultConstructor(wellKnownTypes); + attribute.AddDefaultConstructor(wellKnownTypes.TypeSystem); attribute.CustomAttributes.Add(attributeFactory.AttributeUsage(AttributeTargets.Method, inherited: false)); assemblyDefinition.MainModule.Types.Add(attribute); @@ -405,7 +447,7 @@ private static TypeDefinition DefineDoesNotReturnIfAttribute(AssemblyDefinition TypeAttributes.NotPublic | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, wellKnownTypes.Module.ImportReference(wellKnownTypes.SystemAttribute)); - var constructor = MethodFactory.Constructor(wellKnownTypes); + var constructor = MethodFactory.Constructor(wellKnownTypes.TypeSystem); constructor.Parameters.Add(new ParameterDefinition("parameterValue", ParameterAttributes.None, wellKnownTypes.TypeSystem.Boolean)); attribute.Methods.Add(constructor); @@ -424,7 +466,7 @@ private static TypeDefinition DefineMaybeNullAttribute(AssemblyDefinition assemb TypeAttributes.NotPublic | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, wellKnownTypes.Module.ImportReference(wellKnownTypes.SystemAttribute)); - attribute.AddDefaultConstructor(wellKnownTypes); + attribute.AddDefaultConstructor(wellKnownTypes.TypeSystem); attribute.CustomAttributes.Add(attributeFactory.AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, inherited: false)); assemblyDefinition.MainModule.Types.Add(attribute); @@ -440,7 +482,7 @@ private static TypeDefinition DefineMaybeNullWhenAttribute(AssemblyDefinition as TypeAttributes.NotPublic | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, wellKnownTypes.Module.ImportReference(wellKnownTypes.SystemAttribute)); - var constructor = MethodFactory.Constructor(wellKnownTypes); + var constructor = MethodFactory.Constructor(wellKnownTypes.TypeSystem); constructor.Parameters.Add(new ParameterDefinition("returnValue", ParameterAttributes.None, wellKnownTypes.TypeSystem.Boolean)); attribute.Methods.Add(constructor); @@ -459,7 +501,7 @@ private static TypeDefinition DefineNotNullAttribute(AssemblyDefinition assembly TypeAttributes.NotPublic | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, wellKnownTypes.Module.ImportReference(wellKnownTypes.SystemAttribute)); - attribute.AddDefaultConstructor(wellKnownTypes); + attribute.AddDefaultConstructor(wellKnownTypes.TypeSystem); attribute.CustomAttributes.Add(attributeFactory.AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, inherited: false)); assemblyDefinition.MainModule.Types.Add(attribute); @@ -479,7 +521,7 @@ private static TypeDefinition DefineNotNullIfNotNullAttribute(AssemblyDefinition attribute.CustomAttributes.Add(attributeFactory.Nullable(0)); attribute.CustomAttributes.Add(attributeFactory.AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, allowMultiple: true, inherited: false)); - var constructor = MethodFactory.Constructor(wellKnownTypes); + var constructor = MethodFactory.Constructor(wellKnownTypes.TypeSystem); constructor.Parameters.Add(new ParameterDefinition("parameterName", ParameterAttributes.None, wellKnownTypes.TypeSystem.String)); attribute.Methods.Add(constructor); @@ -496,7 +538,7 @@ private static TypeDefinition DefineNotNullWhenAttribute(AssemblyDefinition asse TypeAttributes.NotPublic | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, wellKnownTypes.Module.ImportReference(wellKnownTypes.SystemAttribute)); - var constructor = MethodFactory.Constructor(wellKnownTypes); + var constructor = MethodFactory.Constructor(wellKnownTypes.TypeSystem); constructor.Parameters.Add(new ParameterDefinition("returnValue", ParameterAttributes.None, wellKnownTypes.TypeSystem.Boolean)); attribute.Methods.Add(constructor); @@ -506,5 +548,19 @@ private static TypeDefinition DefineNotNullWhenAttribute(AssemblyDefinition asse return attribute; } + + private static void EnsureReferenceAssemblyAttribute(AssemblyDefinition assemblyDefinition, CustomAttributeFactory attributeFactory) + { + foreach (var attribute in assemblyDefinition.CustomAttributes) + { + if (attribute.AttributeType.FullName == typeof(ReferenceAssemblyAttribute).FullName) + { + return; + } + } + + var customAttribute = attributeFactory.ReferenceAssembly(); + assemblyDefinition.CustomAttributes.Add(customAttribute); + } } } diff --git a/TunnelVisionLabs.ReferenceAssemblyAnnotator/TunnelVisionLabs.ReferenceAssemblyAnnotator.csproj b/TunnelVisionLabs.ReferenceAssemblyAnnotator/TunnelVisionLabs.ReferenceAssemblyAnnotator.csproj index e0c23d3..3547a2f 100644 --- a/TunnelVisionLabs.ReferenceAssemblyAnnotator/TunnelVisionLabs.ReferenceAssemblyAnnotator.csproj +++ b/TunnelVisionLabs.ReferenceAssemblyAnnotator/TunnelVisionLabs.ReferenceAssemblyAnnotator.csproj @@ -3,6 +3,7 @@ netstandard2.0;net472 + $(NoWarn),NU5128 true true true diff --git a/TunnelVisionLabs.ReferenceAssemblyAnnotator/TunnelVisionLabs.ReferenceAssemblyAnnotator.targets b/TunnelVisionLabs.ReferenceAssemblyAnnotator/TunnelVisionLabs.ReferenceAssemblyAnnotator.targets index 487b240..fa497a0 100644 --- a/TunnelVisionLabs.ReferenceAssemblyAnnotator/TunnelVisionLabs.ReferenceAssemblyAnnotator.targets +++ b/TunnelVisionLabs.ReferenceAssemblyAnnotator/TunnelVisionLabs.ReferenceAssemblyAnnotator.targets @@ -55,6 +55,8 @@ Inputs="@(AvailableUnannotatedReferenceAssembly);@(AnnotatedReferenceAssembly)" Outputs="@(UnannotatedReferenceAssembly->'%(OutputAssembly)')"> + + defineReferenceAssemblyAttribute) { - Module = module; + Module = assemblyDefinition.MainModule; - SystemAttribute = ResolveWellKnownType(module, typeof(Attribute)); - SystemAttributeTargets = ResolveWellKnownType(module, typeof(AttributeTargets)); - SystemAttributeUsageAttribute = ResolveWellKnownType(module, typeof(AttributeUsageAttribute)); - SystemRuntimeCompilerServicesCompilerGeneratedAttribute = ResolveWellKnownType(module, typeof(CompilerGeneratedAttribute)); + SystemAttribute = ResolveRequiredWellKnownType(Module, typeof(Attribute)); + SystemAttributeTargets = ResolveRequiredWellKnownType(Module, typeof(AttributeTargets)); + SystemAttributeUsageAttribute = ResolveRequiredWellKnownType(Module, typeof(AttributeUsageAttribute)); + SystemRuntimeCompilerServicesCompilerGeneratedAttribute = ResolveRequiredWellKnownType(Module, typeof(CompilerGeneratedAttribute)); + + SystemRuntimeCompilerServicesReferenceAssemblyAttribute = ResolveWellKnownType(Module, typeof(ReferenceAssemblyAttribute)) + ?? defineReferenceAssemblyAttribute( + assemblyDefinition, + (systemAttribute: SystemAttribute, systemRuntimeCompilerServicesCompilerGeneratedAttribute: SystemRuntimeCompilerServicesCompilerGeneratedAttribute)); } public ModuleDefinition Module { get; } @@ -31,7 +36,15 @@ public WellKnownTypes(ModuleDefinition module) public TypeReference SystemRuntimeCompilerServicesCompilerGeneratedAttribute { get; } - private static TypeDefinition ResolveWellKnownType(ModuleDefinition module, Type type) + public TypeReference SystemRuntimeCompilerServicesReferenceAssemblyAttribute { get; } + + private static TypeDefinition ResolveRequiredWellKnownType(ModuleDefinition module, Type type) + { + return ResolveWellKnownType(module, type) + ?? throw new NotSupportedException($"Failed to resolve type '{type.FullName}'"); + } + + private static TypeDefinition? ResolveWellKnownType(ModuleDefinition module, Type type) { return module.TypeSystem.Object.Resolve().Module.GetType(type.FullName); } diff --git a/global.json b/global.json index 9847f02..40f698c 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,6 @@ { "sdk": { - "version": "2.1.801" + "version": "3.0.100", + "rollForward": "latestFeature" } }