Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/NRefactory.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <llsan@microsoft.com>2021-08-24 10:08:35 +0300
committerLluis Sanchez <llsan@microsoft.com>2021-08-24 10:08:35 +0300
commita6885a748fbdb95a904572b93f9bcceeb86bcf88 (patch)
tree848a6d94910ba00d0f52bd638d179d371b5ec0c2 /ICSharpCode.NRefactory.CSharp
parent60ac8e99c51e43a58a4dc124b9680fb73c2f974b (diff)
Allow building with .NET 6
Ported projects to sdk-style and added ifdefs to allow compiling with .NET 6
Diffstat (limited to 'ICSharpCode.NRefactory.CSharp')
-rw-r--r--ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj10
-rw-r--r--ICSharpCode.NRefactory.CSharp/OutputVisitor/CodeDomConvertVisitor.cs4
-rw-r--r--ICSharpCode.NRefactory.CSharp/Parser/mcs/assembly.cs34
-rw-r--r--ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs2
-rw-r--r--ICSharpCode.NRefactory.CSharp/Parser/mcs/driver.cs2
-rw-r--r--ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs6
-rw-r--r--ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs18
-rw-r--r--ICSharpCode.NRefactory.CSharp/Parser/mcs/reflection.cs16
8 files changed, 72 insertions, 20 deletions
diff --git a/ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj b/ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj
index 0d12aaaf..9a2fb47f 100644
--- a/ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj
+++ b/ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj
@@ -1,5 +1,5 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
+<?xml version="1.0" encoding="utf-8"?>
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{53DCA265-3C3C-42F9-B647-F72BA678122B}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -23,7 +23,10 @@
<NoWin32Manifest>False</NoWin32Manifest>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DocumentationFile>$(IntermediateOutputPath)ICSharpCode.NRefactory.CSharp.xml</DocumentationFile>
- </PropertyGroup>
+ <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
+ <EnableDefaultCompileItems>False</EnableDefaultCompileItems>
+ <EnableDefaultEmbeddedResourceItems>False</EnableDefaultEmbeddedResourceItems>
+ <TargetFramework>net472</TargetFramework> </PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<RegisterForComInterop>False</RegisterForComInterop>
@@ -396,7 +399,6 @@
<Name>ICSharpCode.NRefactory</Name>
</ProjectReference>
</ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup />
<ProjectExtensions>
<MonoDevelop>
diff --git a/ICSharpCode.NRefactory.CSharp/OutputVisitor/CodeDomConvertVisitor.cs b/ICSharpCode.NRefactory.CSharp/OutputVisitor/CodeDomConvertVisitor.cs
index da1f4d6e..298c303c 100644
--- a/ICSharpCode.NRefactory.CSharp/OutputVisitor/CodeDomConvertVisitor.cs
+++ b/ICSharpCode.NRefactory.CSharp/OutputVisitor/CodeDomConvertVisitor.cs
@@ -16,6 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
+#if !NET6_0
+
using System;
using System.CodeDom;
using System.Collections.Generic;
@@ -1427,3 +1429,5 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
}
+
+#endif \ No newline at end of file
diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/assembly.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/assembly.cs
index 0850e720..75281ba5 100644
--- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/assembly.cs
+++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/assembly.cs
@@ -462,7 +462,11 @@ namespace ICSharpCode.NRefactory.MonoCSharp
// but returned ISymbolWriter does not have all what we need therefore some
// adaptor will be needed for now we alwayas emit MDB format when generating
// debug info
+#if NET6_0
+ return Builder.DefineDynamicModule(module_name);
+#else
return Builder.DefineDynamicModule (module_name, module_name, false);
+#endif
}
public virtual void Emit ()
@@ -787,11 +791,13 @@ namespace ICSharpCode.NRefactory.MonoCSharp
//
// Add Win32 resources
//
+#if !NET6_0
if (Compiler.Settings.Win32ResourceFile != null) {
Builder.DefineUnmanagedResource (Compiler.Settings.Win32ResourceFile);
} else {
Builder.DefineVersionInfoResource (vi_product, vi_product_version, vi_company, vi_copyright, vi_trademark);
}
+#endif
if (Compiler.Settings.Win32IconFile != null) {
builder_extra.DefineWin32IconResource (Compiler.Settings.Win32IconFile);
@@ -819,9 +825,13 @@ namespace ICSharpCode.NRefactory.MonoCSharp
stream = new MemoryStream (File.ReadAllBytes (res.FileName));
}
+#if !NET6_0
module.Builder.DefineManifestResource (res.Name, stream, res.Attributes);
+#endif
} else {
+#if !NET6_0
Builder.AddResourceFile (res.Name, Path.GetFileName (res.FileName), res.Attributes);
+#endif
}
}
}
@@ -871,7 +881,11 @@ namespace ICSharpCode.NRefactory.MonoCSharp
if (Compiler.Settings.Target == Target.Module) {
SaveModule (pekind, machine);
} else {
+#if NET6_0
+ throw new NotSupportedException();
+#else
Builder.Save (module.Builder.ScopeName, pekind, machine);
+#endif
}
} catch (Exception e) {
Report.Error (16, "Could not write to file `" + name + "', cause: " + e.Message);
@@ -964,7 +978,9 @@ namespace ICSharpCode.NRefactory.MonoCSharp
return;
}
+#if !NET6_0
Builder.SetEntryPoint (entry_point.MethodBuilder, file_kind);
+#endif
}
void Error_ObsoleteSecurityAttribute (Attribute a, string option)
@@ -1043,14 +1059,14 @@ namespace ICSharpCode.NRefactory.MonoCSharp
public string FileName { get; private set; }
public bool IsEmbeded { get; set; }
- #region IEquatable<AssemblyResource> Members
+#region IEquatable<AssemblyResource> Members
public bool Equals (AssemblyResource other)
{
return Name == other.Name;
}
- #endregion
+#endregion
}
//
@@ -1258,4 +1274,16 @@ namespace ICSharpCode.NRefactory.MonoCSharp
compiler.TimeReporter.Stop (TimeReporter.TimerType.ReferencesLoading);
}
}
-}
+
+#if NET6_0
+
+ enum PEFileKinds
+ {
+ Dll = 1,
+ ConsoleApplication = 2,
+ WindowApplication = 3
+ }
+
+#endif
+
+ }
diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs
index d14c5953..d43f3510 100644
--- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs
+++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs
@@ -2766,7 +2766,7 @@ namespace ICSharpCode.NRefactory.MonoCSharp
foreach (var de in declarative_security) {
#if STATIC
TypeBuilder.__AddDeclarativeSecurity (de);
-#else
+#elif !NET6_0
TypeBuilder.AddDeclarativeSecurity (de.Key, de.Value);
#endif
}
diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/driver.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/driver.cs
index dd726110..1d1e7b4c 100644
--- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/driver.cs
+++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/driver.cs
@@ -357,8 +357,10 @@ namespace ICSharpCode.NRefactory.MonoCSharp
if (!ctx.BuiltinTypes.CheckDefinitions (module))
return false;
+#if !NET6_0
if (!assembly.Create (AppDomain.CurrentDomain, AssemblyBuilderAccess.Save))
return false;
+#endif
module.CreateContainer ();
diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs
index 17f29cc1..81a237e5 100644
--- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs
+++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs
@@ -686,7 +686,11 @@ namespace ICSharpCode.NRefactory.MonoCSharp
AssemblyBuilderAccess access;
if (Environment.GetEnvironmentVariable ("SAVE") != null) {
+#if NET6_0
+ access = AssemblyBuilderAccess.Run;
+#else
access = AssemblyBuilderAccess.RunAndSave;
+#endif
assembly = new AssemblyDefinitionDynamic (module, current_debug_name, current_debug_name);
assembly.Importer = importer;
} else {
@@ -786,8 +790,10 @@ namespace ICSharpCode.NRefactory.MonoCSharp
if (host != null)
host.CloseContainer ();
+#if !NET6_0
if (access == AssemblyBuilderAccess.RunAndSave)
assembly.Save ();
+#endif
if (host == null)
return null;
diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs
index 0ce37f6b..baf44242 100644
--- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs
+++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs
@@ -711,7 +711,7 @@ namespace ICSharpCode.NRefactory.MonoCSharp {
foreach (var de in declarative_security) {
#if STATIC
MethodBuilder.__AddDeclarativeSecurity (de);
-#else
+#elif !NET6_0
MethodBuilder.AddDeclarativeSecurity (de.Key, de.Value);
#endif
}
@@ -1801,7 +1801,7 @@ namespace ICSharpCode.NRefactory.MonoCSharp {
foreach (var de in declarative_security) {
#if STATIC
ConstructorBuilder.__AddDeclarativeSecurity (de);
-#else
+#elif !NET6_0
ConstructorBuilder.AddDeclarativeSecurity (de.Key, de.Value);
#endif
}
@@ -1861,6 +1861,7 @@ namespace ICSharpCode.NRefactory.MonoCSharp {
if (debug_builder == null)
return;
+#if !NET6_0
var token = ConstructorBuilder.GetToken ();
int t = token.Token;
#if STATIC
@@ -1869,9 +1870,10 @@ namespace ICSharpCode.NRefactory.MonoCSharp {
#endif
debug_builder.DefineMethod (file, t);
+#endif
}
- #region IMethodData Members
+#region IMethodData Members
public MemberName MethodName {
get {
@@ -1890,7 +1892,7 @@ namespace ICSharpCode.NRefactory.MonoCSharp {
throw new NotImplementedException ();
}
- #endregion
+#endregion
}
/// <summary>
@@ -2191,6 +2193,7 @@ namespace ICSharpCode.NRefactory.MonoCSharp {
if (debug_builder == null)
return;
+#if !NET6_0
var token = builder.GetToken ();
int t = token.Token;
#if STATIC
@@ -2199,6 +2202,7 @@ namespace ICSharpCode.NRefactory.MonoCSharp {
#endif
debug_builder.DefineMethod (file, t);
+#endif
}
}
@@ -2337,7 +2341,7 @@ namespace ICSharpCode.NRefactory.MonoCSharp {
SetMemberName (SetupName (prefix, member, Location));
}
- #region IMethodData Members
+#region IMethodData Members
public ToplevelBlock Block {
get {
@@ -2387,7 +2391,7 @@ namespace ICSharpCode.NRefactory.MonoCSharp {
public abstract ParametersCompiled ParameterInfo { get ; }
public abstract TypeSpec ReturnType { get; }
- #endregion
+#endregion
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
@@ -2454,7 +2458,7 @@ namespace ICSharpCode.NRefactory.MonoCSharp {
foreach (var de in declarative_security) {
#if STATIC
method_data.MethodBuilder.__AddDeclarativeSecurity (de);
-#else
+#elif !NET6_0
method_data.MethodBuilder.AddDeclarativeSecurity (de.Key, de.Value);
#endif
}
diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/reflection.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/reflection.cs
index 936818f0..47d75c6a 100644
--- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/reflection.cs
+++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/reflection.cs
@@ -209,17 +209,21 @@ namespace ICSharpCode.NRefactory.MonoCSharp
public override ModuleBuilder CreateModuleBuilder ()
{
if (file_name == null)
+#if NET6_0
+ return Builder.DefineDynamicModule(Name);
+#else
return Builder.DefineDynamicModule (Name, false);
+#endif
return base.CreateModuleBuilder ();
}
#endif
- //
- // Initializes the code generator
- //
+ //
+ // Initializes the code generator
+ //
public bool Create (AppDomain domain, AssemblyBuilderAccess access)
{
-#if STATIC || FULL_AOT_RUNTIME
+#if STATIC || FULL_AOT_RUNTIME || NETCOREAPP
throw new NotSupportedException ();
#else
ResolveAssemblySecurityAttributes ();
@@ -261,10 +265,12 @@ namespace ICSharpCode.NRefactory.MonoCSharp
base.SaveModule (pekind, machine);
}
+#if !NETCOREAPP
Builder.Save (file_name, pekind, machine);
+#endif
}
#endif
- }
+ }
//
// Extension to System.Reflection.Emit.AssemblyBuilder to have fully compatible