Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add check for system assemblies completion #10575

Merged
merged 3 commits into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 156 additions & 0 deletions src/fsharp/DotNetFrameworkDependencies.fs
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,162 @@ module internal FSharp.Compiler.DotNetFrameworkDependencies
yield "System.Threading.Tasks.Extensions"
yield "System.Xml.ReaderWriter"
yield "System.Xml.XDocument"

// .NET 5.0 list
yield "System.Numerics"
yield "netstandard"
yield "Microsoft.CSharp"
yield "Microsoft.VisualBasic.Core"
yield "Microsoft.VisualBasic"
yield "Microsoft.Win32.Primitives"
yield "mscorlib"
yield "netstandard"
yield "System.AppContext"
yield "System.Buffers"
yield "System.Collections.Concurrent"
yield "System.Collections"
yield "System.Collections.Immutable"
yield "System.Collections.NonGeneric"
yield "System.Collections.Specialized"
yield "System.ComponentModel.Annotations"
yield "System.ComponentModel.DataAnnotations"
yield "System.ComponentModel"
yield "System.ComponentModel.EventBasedAsync"
yield "System.ComponentModel.Primitives"
yield "System.ComponentModel.TypeConverter"
yield "System.Configuration"
yield "System.Console"
yield "System.Core"
yield "System.Data.Common"
yield "System.Data.DataSetExtensions"
yield "System.Data"
yield "System.Diagnostics.Contracts"
yield "System.Diagnostics.Debug"
yield "System.Diagnostics.DiagnosticSource"
yield "System.Diagnostics.FileVersionInfo"
yield "System.Diagnostics.Process"
yield "System.Diagnostics.StackTrace"
yield "System.Diagnostics.TextWriterTraceListener"
yield "System.Diagnostics.Tools"
yield "System.Diagnostics.TraceSource"
yield "System.Diagnostics.Tracing"
yield "System"
yield "System.Drawing"
yield "System.Drawing.Primitives"
yield "System.Dynamic.Runtime"
yield "System.Formats.Asn1"
yield "System.Globalization.Calendars"
yield "System.Globalization"
yield "System.Globalization.Extensions"
yield "System.IO.Compression.Brotli"
yield "System.IO.Compression"
yield "System.IO.Compression.FileSystem"
yield "System.IO.Compression.ZipFile"
yield "System.IO"
yield "System.IO.FileSystem"
yield "System.IO.FileSystem.DriveInfo"
yield "System.IO.FileSystem.Primitives"
yield "System.IO.FileSystem.Watcher"
yield "System.IO.IsolatedStorage"
yield "System.IO.MemoryMappedFiles"
yield "System.IO.Pipes"
yield "System.IO.UnmanagedMemoryStream"
yield "System.Linq"
yield "System.Linq.Expressions"
yield "System.Linq.Parallel"
yield "System.Linq.Queryable"
yield "System.Memory"
yield "System.Net"
yield "System.Net.Http"
yield "System.Net.Http.Json"
yield "System.Net.HttpListener"
yield "System.Net.Mail"
yield "System.Net.NameResolution"
yield "System.Net.NetworkInformation"
yield "System.Net.Ping"
yield "System.Net.Primitives"
yield "System.Net.Requests"
yield "System.Net.Security"
yield "System.Net.ServicePoint"
yield "System.Net.Sockets"
yield "System.Net.WebClient"
yield "System.Net.WebHeaderCollection"
yield "System.Net.WebProxy"
yield "System.Net.WebSockets.Client"
yield "System.Net.WebSockets"
yield "System.Numerics"
yield "System.Numerics.Vectors"
yield "System.ObjectModel"
yield "System.Reflection.DispatchProxy"
yield "System.Reflection"
yield "System.Reflection.Emit"
yield "System.Reflection.Emit.ILGeneration"
yield "System.Reflection.Emit.Lightweight"
yield "System.Reflection.Extensions"
yield "System.Reflection.Metadata"
yield "System.Reflection.Primitives"
yield "System.Reflection.TypeExtensions"
yield "System.Resources.Reader"
yield "System.Resources.ResourceManager"
yield "System.Resources.Writer"
yield "System.Runtime.CompilerServices.Unsafe"
yield "System.Runtime.CompilerServices.VisualC"
yield "System.Runtime"
yield "System.Runtime.Extensions"
yield "System.Runtime.Handles"
yield "System.Runtime.InteropServices"
yield "System.Runtime.InteropServices.RuntimeInformation"
yield "System.Runtime.Intrinsics"
yield "System.Runtime.Loader"
yield "System.Runtime.Numerics"
yield "System.Runtime.Serialization"
yield "System.Runtime.Serialization.Formatters"
yield "System.Runtime.Serialization.Json"
yield "System.Runtime.Serialization.Primitives"
yield "System.Runtime.Serialization.Xml"
yield "System.Security.Claims"
yield "System.Security.Cryptography.Algorithms"
yield "System.Security.Cryptography.Csp"
yield "System.Security.Cryptography.Encoding"
yield "System.Security.Cryptography.Primitives"
yield "System.Security.Cryptography.X509Certificates"
yield "System.Security"
yield "System.Security.Principal"
yield "System.Security.SecureString"
yield "System.ServiceModel.Web"
yield "System.ServiceProcess"
yield "System.Text.Encoding.CodePages"
yield "System.Text.Encoding"
yield "System.Text.Encoding.Extensions"
yield "System.Text.Encodings.Web"
yield "System.Text.Json"
yield "System.Text.RegularExpressions"
yield "System.Threading.Channels"
yield "System.Threading"
yield "System.Threading.Overlapped"
yield "System.Threading.Tasks.Dataflow"
yield "System.Threading.Tasks"
yield "System.Threading.Tasks.Extensions"
yield "System.Threading.Tasks.Parallel"
yield "System.Threading.Thread"
yield "System.Threading.ThreadPool"
yield "System.Threading.Timer"
yield "System.Transactions"
yield "System.Transactions.Local"
yield "System.ValueTuple"
yield "System.Web"
yield "System.Web.HttpUtility"
yield "System.Windows"
yield "System.Xml"
yield "System.Xml.Linq"
yield "System.Xml.ReaderWriter"
yield "System.Xml.Serialization"
yield "System.Xml.XDocument"
yield "System.Xml.XmlDocument"
yield "System.Xml.XmlSerializer"
yield "System.Xml.XPath"
yield "System.Xml.XPath.XDocument"
yield "WindowsBase"
dsyme marked this conversation as resolved.
Show resolved Hide resolved
]

// The set of references entered into the TcConfigBuilder for scripts prior to computing the load closure.
Expand Down
22 changes: 21 additions & 1 deletion tests/service/ScriptOptionsTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,24 @@ let ``can generate options for different frameworks regardless of execution envi
|> Async.RunSynchronously
match errors with
| [] -> ()
| errors -> failwithf "Error while parsing script with assumeDotNetFramework:%b, useSdkRefs:%b, and otherFlags:%A:\n%A" assumeNetFx useSdk flags errors
| errors -> failwithf "Error while parsing script with assumeDotNetFramework:%b, useSdkRefs:%b, and otherFlags:%A:\n%A" assumeNetFx useSdk flags errors

[<TestCase(true, false, [| "--targetprofile:mscorlib" |])>]
[<TestCase(false, true, [| "--targetprofile:netcore" |])>]
[<Test>]
let ``all default assembly references are system assemblies``(assumeNetFx, useSdk, flags) =
let path = Path.GetTempPath()
let file = Path.GetTempFileName()
let tempFile = Path.Combine(path, file)
let (options, errors) =
checker.GetProjectOptionsFromScript(tempFile, SourceText.ofString scriptSource, assumeDotNetFramework = assumeNetFx, useSdkRefs = useSdk, otherFlags = flags)
|> Async.RunSynchronously
match errors with
| [] -> ()
| errors -> failwithf "Error while parsing script with assumeDotNetFramework:%b, useSdkRefs:%b, and otherFlags:%A:\n%A" assumeNetFx useSdk flags errors
for r in options.OtherOptions do
if r.StartsWith("-r:") then
let ref = Path.GetFullPath(r.[3..])
let baseName = Path.GetFileNameWithoutExtension(ref)
if not (FSharp.Compiler.DotNetFrameworkDependencies.systemAssemblies.Contains(baseName)) then
failwithf "expected FSharp.Compiler.DotNetFrameworkDependencies.systemAssemblies to contain '%s' because '%s' is a default reference for a script, (assumeNetFx, useSdk, flags) = %A" baseName ref (assumeNetFx, useSdk, flags)