Skip to content

Commit

Permalink
Extra info added
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredpar committed Aug 23, 2024
1 parent d3ad7d0 commit b05727a
Show file tree
Hide file tree
Showing 10 changed files with 496 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net461" Version="1.0.3" IncludeAssets="none" PrivateAssets="all" GeneratePathProperty="true" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" IncludeAssets="none" PrivateAssets="all" GeneratePathProperty="true" />
</ItemGroup>

<Import Project="Generated.targets" />
Expand Down
74 changes: 74 additions & 0 deletions Src/Basic.Reference.Assemblies.Net461/Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,74 @@
using Microsoft.CodeAnalysis;

namespace Basic.Reference.Assemblies;
public static partial class Net461
{
public static class ExtraReferenceInfos
{

/// <summary>
/// The <see cref="ReferenceInfo"/> for System.Threading.Tasks.Extensions.dll
/// </summary>
public static ReferenceInfo SystemThreadingTasksExtensions => new ReferenceInfo("System.Threading.Tasks.Extensions.dll", Resources.SystemThreadingTasksExtensions, Net461.ExtraReferences.SystemThreadingTasksExtensions, global::System.Guid.Parse("bc890e4e-a34f-463c-8fd9-60f43c8beb88"));
private static ImmutableArray<ReferenceInfo> _all;
public static ImmutableArray<ReferenceInfo> All
{
get
{
if (_all.IsDefault)
{
_all =
[
SystemThreadingTasksExtensions,
];
}
return _all;
}
}

public static IEnumerable<(string FileName, byte[] ImageBytes, PortableExecutableReference Reference, Guid Mvid)> AllValues => All.Select(x => x.AsTuple());
}
}

public static partial class Net461
{
public static class ExtraReferences
{
private static PortableExecutableReference? _SystemThreadingTasksExtensions;

/// <summary>
/// The <see cref="PortableExecutableReference"/> for System.Threading.Tasks.Extensions.dll
/// </summary>
public static PortableExecutableReference SystemThreadingTasksExtensions
{
get
{
if (_SystemThreadingTasksExtensions is null)
{
_SystemThreadingTasksExtensions = AssemblyMetadata.CreateFromImage(Resources.SystemThreadingTasksExtensions).GetReference(filePath: "System.Threading.Tasks.Extensions.dll", display: "System.Threading.Tasks.Extensions (net461)");
}
return _SystemThreadingTasksExtensions;
}
}

private static ImmutableArray<PortableExecutableReference> _all;
public static ImmutableArray<PortableExecutableReference> All
{
get
{
if (_all.IsDefault)
{
_all =
[
SystemThreadingTasksExtensions,
];
}
return _all;
}
}
}
}

public static partial class Net461
{
public static class Resources
Expand Down Expand Up @@ -1115,6 +1183,12 @@ public static class Resources
public static byte[] SystemXmlXmlSerializer => ResourceLoader.GetOrCreateResource(ref _SystemXmlXmlSerializer, "net461.System.Xml.XmlSerializer");
private static byte[]? _SystemXmlXmlSerializer;

/// <summary>
/// The image bytes for System.Threading.Tasks.Extensions.dll
/// </summary>
public static byte[] SystemThreadingTasksExtensions => ResourceLoader.GetOrCreateResource(ref _SystemThreadingTasksExtensions, "net461.System.Threading.Tasks.Extensions");
private static byte[]? _SystemThreadingTasksExtensions;


}
}
Expand Down
4 changes: 4 additions & 0 deletions Src/Basic.Reference.Assemblies.Net461/Generated.targets
Original file line number Diff line number Diff line change
Expand Up @@ -736,5 +736,9 @@
<LogicalName>net461.System.Xml.XmlSerializer</LogicalName>
<Link>Resources\net461\System.Xml.XmlSerializer.dll</Link>
</EmbeddedResource>
<EmbeddedResource Include="$(NuGetPackageRoot)\system.threading.tasks.extensions\4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll" WithCulture="false">
<LogicalName>net461.System.Threading.Tasks.Extensions</LogicalName>
<Link>Resources\net461\System.Threading.Tasks.Extensions.dll</Link>
</EmbeddedResource>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" IncludeAssets="none" PrivateAssets="all" GeneratePathProperty="true" />
<PackageReference Include="Microsoft.VisualBasic" Version="10.3.0" IncludeAssets="none" PrivateAssets="all" GeneratePathProperty="true" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" IncludeAssets="none" PrivateAssets="all" GeneratePathProperty="true" />
</ItemGroup>

<Import Project="Generated.targets" />
Expand Down
134 changes: 134 additions & 0 deletions Src/Basic.Reference.Assemblies.NetStandard20/Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,122 @@
using Microsoft.CodeAnalysis;

namespace Basic.Reference.Assemblies;
public static partial class NetStandard20
{
public static class ExtraReferenceInfos
{

/// <summary>
/// The <see cref="ReferenceInfo"/> for Microsoft.CSharp.dll
/// </summary>
public static ReferenceInfo MicrosoftCSharp => new ReferenceInfo("Microsoft.CSharp.dll", Resources.MicrosoftCSharp, NetStandard20.ExtraReferences.MicrosoftCSharp, global::System.Guid.Parse("481b904b-3433-4e80-b896-766a3cc8e857"));

/// <summary>
/// The <see cref="ReferenceInfo"/> for Microsoft.VisualBasic.dll
/// </summary>
public static ReferenceInfo MicrosoftVisualBasic => new ReferenceInfo("Microsoft.VisualBasic.dll", Resources.MicrosoftVisualBasic, NetStandard20.ExtraReferences.MicrosoftVisualBasic, global::System.Guid.Parse("b61ee3c6-71d0-4726-931a-fa448a2e8f0e"));

/// <summary>
/// The <see cref="ReferenceInfo"/> for System.Threading.Tasks.Extensions.dll
/// </summary>
public static ReferenceInfo SystemThreadingTasksExtensions => new ReferenceInfo("System.Threading.Tasks.Extensions.dll", Resources.SystemThreadingTasksExtensions, NetStandard20.ExtraReferences.SystemThreadingTasksExtensions, global::System.Guid.Parse("619062a8-972f-4ae5-bbee-e36ac541d14f"));
private static ImmutableArray<ReferenceInfo> _all;
public static ImmutableArray<ReferenceInfo> All
{
get
{
if (_all.IsDefault)
{
_all =
[
MicrosoftCSharp,
MicrosoftVisualBasic,
SystemThreadingTasksExtensions,
];
}
return _all;
}
}

public static IEnumerable<(string FileName, byte[] ImageBytes, PortableExecutableReference Reference, Guid Mvid)> AllValues => All.Select(x => x.AsTuple());
}
}

public static partial class NetStandard20
{
public static class ExtraReferences
{
private static PortableExecutableReference? _MicrosoftCSharp;

/// <summary>
/// The <see cref="PortableExecutableReference"/> for Microsoft.CSharp.dll
/// </summary>
public static PortableExecutableReference MicrosoftCSharp
{
get
{
if (_MicrosoftCSharp is null)
{
_MicrosoftCSharp = AssemblyMetadata.CreateFromImage(Resources.MicrosoftCSharp).GetReference(filePath: "Microsoft.CSharp.dll", display: "Microsoft.CSharp (netstandard20)");
}
return _MicrosoftCSharp;
}
}

private static PortableExecutableReference? _MicrosoftVisualBasic;

/// <summary>
/// The <see cref="PortableExecutableReference"/> for Microsoft.VisualBasic.dll
/// </summary>
public static PortableExecutableReference MicrosoftVisualBasic
{
get
{
if (_MicrosoftVisualBasic is null)
{
_MicrosoftVisualBasic = AssemblyMetadata.CreateFromImage(Resources.MicrosoftVisualBasic).GetReference(filePath: "Microsoft.VisualBasic.dll", display: "Microsoft.VisualBasic (netstandard20)");
}
return _MicrosoftVisualBasic;
}
}

private static PortableExecutableReference? _SystemThreadingTasksExtensions;

/// <summary>
/// The <see cref="PortableExecutableReference"/> for System.Threading.Tasks.Extensions.dll
/// </summary>
public static PortableExecutableReference SystemThreadingTasksExtensions
{
get
{
if (_SystemThreadingTasksExtensions is null)
{
_SystemThreadingTasksExtensions = AssemblyMetadata.CreateFromImage(Resources.SystemThreadingTasksExtensions).GetReference(filePath: "System.Threading.Tasks.Extensions.dll", display: "System.Threading.Tasks.Extensions (netstandard20)");
}
return _SystemThreadingTasksExtensions;
}
}

private static ImmutableArray<PortableExecutableReference> _all;
public static ImmutableArray<PortableExecutableReference> All
{
get
{
if (_all.IsDefault)
{
_all =
[
MicrosoftCSharp,
MicrosoftVisualBasic,
SystemThreadingTasksExtensions,
];
}
return _all;
}
}
}
}

public static partial class NetStandard20
{
public static class Resources
Expand Down Expand Up @@ -689,6 +805,24 @@ public static class Resources
public static byte[] SystemXmlXPathXDocument => ResourceLoader.GetOrCreateResource(ref _SystemXmlXPathXDocument, "netstandard20.System.Xml.XPath.XDocument");
private static byte[]? _SystemXmlXPathXDocument;

/// <summary>
/// The image bytes for Microsoft.CSharp.dll
/// </summary>
public static byte[] MicrosoftCSharp => ResourceLoader.GetOrCreateResource(ref _MicrosoftCSharp, "netstandard20.Microsoft.CSharp");
private static byte[]? _MicrosoftCSharp;

/// <summary>
/// The image bytes for Microsoft.VisualBasic.dll
/// </summary>
public static byte[] MicrosoftVisualBasic => ResourceLoader.GetOrCreateResource(ref _MicrosoftVisualBasic, "netstandard20.Microsoft.VisualBasic");
private static byte[]? _MicrosoftVisualBasic;

/// <summary>
/// The image bytes for System.Threading.Tasks.Extensions.dll
/// </summary>
public static byte[] SystemThreadingTasksExtensions => ResourceLoader.GetOrCreateResource(ref _SystemThreadingTasksExtensions, "netstandard20.System.Threading.Tasks.Extensions");
private static byte[]? _SystemThreadingTasksExtensions;


}
}
Expand Down
12 changes: 12 additions & 0 deletions Src/Basic.Reference.Assemblies.NetStandard20/Generated.targets
Original file line number Diff line number Diff line change
Expand Up @@ -452,5 +452,17 @@
<LogicalName>netstandard20.System.Xml.XPath.XDocument</LogicalName>
<Link>Resources\netstandard20\System.Xml.XPath.XDocument.dll</Link>
</EmbeddedResource>
<EmbeddedResource Include="$(NuGetPackageRoot)\microsoft.csharp\4.7.0\lib\netstandard2.0\Microsoft.CSharp.dll" WithCulture="false">
<LogicalName>netstandard20.Microsoft.CSharp</LogicalName>
<Link>Resources\netstandard20\Microsoft.CSharp.dll</Link>
</EmbeddedResource>
<EmbeddedResource Include="$(NuGetPackageRoot)\microsoft.visualbasic\10.3.0\lib\netstandard2.0\Microsoft.VisualBasic.dll" WithCulture="false">
<LogicalName>netstandard20.Microsoft.VisualBasic</LogicalName>
<Link>Resources\netstandard20\Microsoft.VisualBasic.dll</Link>
</EmbeddedResource>
<EmbeddedResource Include="$(NuGetPackageRoot)\system.threading.tasks.extensions\4.5.4\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll" WithCulture="false">
<LogicalName>netstandard20.System.Threading.Tasks.Extensions</LogicalName>
<Link>Resources\netstandard20\System.Threading.Tasks.Extensions.dll</Link>
</EmbeddedResource>
</ItemGroup>
</Project>
60 changes: 60 additions & 0 deletions Src/Basic.Reference.Assemblies.UnitTests/SanityUnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,64 @@ public void ReferencesLazyInit()
Assert.NotEmpty(Net461.References.All);
Assert.NotEmpty(Net472.References.All);
}

[Fact]
public void ExtraNetStandard20()
{
var source = """
using System;
public class C
{
public System.Threading.Tasks.ValueTask Field1;
public dynamic Field2;
public Microsoft.VisualBasic.CompilerServices.NewLateBinding Field3;
static void Main()
{
Console.WriteLine("");
}
}
""";

var compilation = CSharpCompilation.Create(
"Example",
[CSharpSyntaxTree.ParseText(source)],
[.. NetStandard20.References.All, .. NetStandard20.ExtraReferences.All]);

Assert.Empty(compilation.GetDiagnostics());
using var stream = new MemoryStream();
var emitResult = compilation.Emit(stream);
Assert.True(emitResult.Success);
Assert.Empty(emitResult.Diagnostics);
}

[Fact]
public void ExtraNetStandardNet461()
{
var source = """
using System;
public class C
{
public System.Threading.Tasks.ValueTask Field1;
static void Main()
{
Console.WriteLine("");
}
}
""";

var compilation = CSharpCompilation.Create(
"Example",
[CSharpSyntaxTree.ParseText(source)],
[.. Net461.References.All, .. Net461.ExtraReferences.All]);

Assert.Empty(compilation.GetDiagnostics());
using var stream = new MemoryStream();
var emitResult = compilation.Emit(stream);
Assert.True(emitResult.Success);
Assert.Empty(emitResult.Diagnostics);
}
}
Loading

0 comments on commit b05727a

Please sign in to comment.