-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Remove MS.CA.Test.Resources.Proprietary PackageReference #75037
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CSharp; | ||
using Microsoft.CodeAnalysis.Emit; | ||
using Microsoft.CodeAnalysis.Test.Utilities; | ||
using Microsoft.CodeAnalysis.Text; | ||
|
||
namespace Roslyn.Test.Utilities; | ||
|
||
/// <summary> | ||
/// The assemblies produced here are designed to mimic the public key token structure of | ||
/// silverlight references. This often presents challenges to the compiler because it has | ||
/// to know that two mscorlib with different public key tokens need to be treated as the | ||
/// identicial. The assemblies produced here have the same identity of those that come | ||
/// from silverlight but without necessarily the same type contents. | ||
/// </summary> | ||
public static class Silverlight | ||
{ | ||
private static readonly Lazy<(byte[], byte[])> s_tuple = new Lazy<(byte[], byte[])>( | ||
() => BuildImages(), | ||
LazyThreadSafetyMode.PublicationOnly); | ||
|
||
public static byte[] Mscorlib => s_tuple.Value.Item1; | ||
|
||
public static byte[] System => s_tuple.Value.Item2; | ||
|
||
private static (byte[], byte[]) BuildImages() | ||
{ | ||
const string corlibExtraCode = """ | ||
using System; | ||
using System.Reflection; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: these usings look unnecessary. Maybe adding VerifyDiagnostics to the compilations we create here would catch that? |
||
|
||
namespace System.Reflection; | ||
|
||
[AttributeUsage(AttributeTargets.Assembly, Inherited = false)] | ||
public sealed class AssemblyFileVersionAttribute : Attribute | ||
{ | ||
public string Version { get; } | ||
public AssemblyFileVersionAttribute(string version) | ||
{ | ||
Version = version; | ||
} | ||
} | ||
[AttributeUsage(AttributeTargets.Assembly, Inherited = false)] | ||
public sealed class AssemblyVersionAttribute : Attribute | ||
{ | ||
public string Version { get; } | ||
public AssemblyVersionAttribute(string version) | ||
{ | ||
Version = version; | ||
} | ||
} | ||
"""; | ||
|
||
const string assemblyAttributes = """ | ||
using System.Reflection; | ||
|
||
[assembly: AssemblyFileVersion("5.0.5.0")] | ||
[assembly: AssemblyVersion("5.0.5.0")] | ||
"""; | ||
|
||
var publicKeyText = "" + | ||
"00240000048000009400000006020000002400005253413100040000010001008d56c76f9e8649383049f" + | ||
"383c44be0ec204181822a6c31cf5eb7ef486944d032188ea1d3920763712ccb12d75fb77e9811149e6148" + | ||
"e5d32fbaab37611c1878ddc19e20ef135d0cb2cff2bfec3d115810c3d9069638fe4be215dbf795861920e" + | ||
"5ab6f7db2e2ceef136ac23d5dd2bf031700aec232f6c6b1c785b4305c123b37ab"; | ||
var publicKey = TestHelpers.HexToByte(publicKeyText.AsSpan()); | ||
var publicKeyToken = AssemblyIdentity.CalculatePublicKeyToken(publicKey); | ||
Debug.Assert("7C-EC-85-D7-BE-A7-79-8E" == BitConverter.ToString(publicKeyToken.ToArray())); | ||
|
||
var options = new CSharpCompilationOptions( | ||
OutputKind.DynamicallyLinkedLibrary, | ||
cryptoPublicKey: publicKey, | ||
optimizationLevel: OptimizationLevel.Release); | ||
var mscorlibCompilation = CSharpCompilation.Create( | ||
"mscorlib", | ||
[ | ||
CSharpSyntaxTree.ParseText(SourceText.From(TestResources.NetFX.Minimal.mincorlib_cs)), | ||
CSharpSyntaxTree.ParseText(SourceText.From(corlibExtraCode)), | ||
CSharpSyntaxTree.ParseText(SourceText.From(assemblyAttributes)), | ||
], | ||
options: options); | ||
|
||
var mscorlib = mscorlibCompilation.EmitToStream(EmitOptions.Default.WithRuntimeMetadataVersion("v4.0.30319")); | ||
|
||
var systemCompilation = CSharpCompilation.Create( | ||
"System", | ||
syntaxTrees: [CSharpSyntaxTree.ParseText(SourceText.From(assemblyAttributes))], | ||
references: [mscorlibCompilation.EmitToImageReference()], | ||
options: options); | ||
|
||
var system = systemCompilation.EmitToStream(); | ||
return (mscorlib.ToArray(), system.ToArray()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CSharp; | ||
using Microsoft.CodeAnalysis.Test.Utilities; | ||
using Microsoft.CodeAnalysis.Text; | ||
|
||
namespace Roslyn.Test.Utilities; | ||
|
||
/// <summary> | ||
/// This type produces stdole.dll that mimic the version used in the original Roslyn | ||
/// interop tests. | ||
/// </summary> | ||
public static class StdOle | ||
{ | ||
public static PortableExecutableReference Build(IEnumerable<MetadataReference> references) | ||
{ | ||
const string assemblyAttributes = """ | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
[assembly: ImportedFromTypeLib("stdole")] | ||
[assembly: Guid("00020430-0000-0000-c000-000000000046")] | ||
[assembly: PrimaryInteropAssembly(2, 0)] | ||
[assembly: AssemblyVersion("7.0.3300.0")] | ||
|
||
"""; | ||
|
||
const string code = """ | ||
using System.Runtime.InteropServices; | ||
namespace stdole; | ||
|
||
public struct GUID | ||
{ | ||
public uint Data1; | ||
public ushort Data2; | ||
public ushort Data3; | ||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] | ||
public byte[] Data4; | ||
} | ||
|
||
[ComImport] | ||
[Guid("00020400-0000-0000-C000-000000000046")] | ||
[TypeLibType(512)] | ||
public interface IDispatch | ||
{ | ||
} | ||
"""; | ||
|
||
var publicKeyText = "" + | ||
"002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e8" + | ||
"4aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980" + | ||
"957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1" + | ||
"dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293"; | ||
var publicKey = TestHelpers.HexToByte(publicKeyText.AsSpan()); | ||
var publicKeyToken = AssemblyIdentity.CalculatePublicKeyToken(publicKey); | ||
Debug.Assert("B0-3F-5F-7F-11-D5-0A-3A" == BitConverter.ToString(publicKeyToken.ToArray())); | ||
|
||
var options = new CSharpCompilationOptions( | ||
OutputKind.DynamicallyLinkedLibrary, | ||
cryptoPublicKey: publicKey, | ||
optimizationLevel: OptimizationLevel.Release); | ||
var compilation = CSharpCompilation.Create( | ||
"stdole", | ||
[ | ||
CSharpSyntaxTree.ParseText(SourceText.From(code)), | ||
CSharpSyntaxTree.ParseText(SourceText.From(assemblyAttributes)) | ||
], | ||
references: references, | ||
options); | ||
|
||
return compilation.EmitToPortableExecutableReference(); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went back and forth on this decision several times. The Silverlight references are only used right now to test assembly unification policies (that I could see). Rather than the overhead of bringing in more .dll files decided to just dynamically build the same assemblies that would let us test unification policy.