Skip to content

Commit

Permalink
Use explicit namespace for proprietary resources (dotnet#45842)
Browse files Browse the repository at this point in the history
* Use explicit namespace for proprietary resources

The Roslyn code base originated with all of our resource reference /
impl DLLs being checked into a single utility project. At the point we
moved to Git and went OSS these single utility project was factored into
two projects for a number of reasons.

1. Keeping DLLs we didn't have license for private
1. Letting us put large binaries into a NuPkg file vs. polluting Git
   history

When this split occured the namespaces for the utility projects were not
updated. That means many types in our public and private resource
projects have the same name. This makes it **really** difficult to
determine where types and resources are coming from.

This change adds an explicit namespace to the proprietary resource
assembly. This will help make it clear which resources come from it.

* Fix version

* Remove version ambigutiy

* Fix test failure
  • Loading branch information
jaredpar authored Jul 22, 2020
1 parent 127aa50 commit b3f5c67
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 54 deletions.
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<MicrosoftCodeAnalysisCSharpCodeRefactoringTestingXUnitVersion>$(MicrosoftCodeAnalysisTestingVersion)</MicrosoftCodeAnalysisCSharpCodeRefactoringTestingXUnitVersion>
<MicrosoftCodeAnalysisCSharpCodeStyleVersion>$(CodeStyleAnalyzerVersion)</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
<MicrosoftCodeAnalysisElfieVersion>0.10.6</MicrosoftCodeAnalysisElfieVersion>
<MicrosoftCodeAnalysisTestResourcesProprietaryVersion>2.0.36</MicrosoftCodeAnalysisTestResourcesProprietaryVersion>
<MicrosoftCodeAnalysisTestResourcesProprietaryVersion>2.0.41</MicrosoftCodeAnalysisTestResourcesProprietaryVersion>
<MicrosoftCodeAnalysisVisualBasicCodeFixTestingXUnitVersion>$(MicrosoftCodeAnalysisTestingVersion)</MicrosoftCodeAnalysisVisualBasicCodeFixTestingXUnitVersion>
<MicrosoftCodeAnalysisVisualBasicCodeRefactoringTestingXUnitVersion>$(MicrosoftCodeAnalysisTestingVersion)</MicrosoftCodeAnalysisVisualBasicCodeRefactoringTestingXUnitVersion>
<MicrosoftCodeAnalysisVisualBasicCodeStyleVersion>$(CodeStyleAnalyzerVersion)</MicrosoftCodeAnalysisVisualBasicCodeStyleVersion>
Expand Down
7 changes: 5 additions & 2 deletions src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Emit;
using Microsoft.CodeAnalysis.Test.Resources.Proprietary;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.Text;
using Microsoft.DiaSymReader;
Expand Down Expand Up @@ -4130,7 +4131,7 @@ public void AppConfigBasic()
</runtime>
</configuration>");

var silverlight = Temp.CreateFile().WriteAllBytes(TestResources.NetFX.silverlight_v5_0_5_0.System_v5_0_5_0_silverlight).Path;
var silverlight = Temp.CreateFile().WriteAllBytes(ProprietaryTestResources.silverlight_v5_0_5_0.System_v5_0_5_0_silverlight).Path;
var net4_0dll = Temp.CreateFile().WriteAllBytes(ResourcesNet451.System).Path;

// Test linking two appconfig dlls with simple src
Expand Down Expand Up @@ -11101,12 +11102,13 @@ public void MissingCompilerAssembly()

#if NET472
[ConditionalFact(typeof(WindowsDesktopOnly), typeof(IsEnglishLocal), Reason = "https://github.com/dotnet/roslyn/issues/30321")]
public void LoadingAnalyzerNetStandard13()
public void LoadinganalyzerNetStandard13()
{
var analyzerFileName = "AnalyzerNS13.dll";
var srcFileName = "src.cs";

var analyzerDir = Temp.CreateDirectory();

var analyzerFile = analyzerDir.CreateFile(analyzerFileName).WriteAllBytes(DesktopTestHelpers.CreateCSharpAnalyzerNetStandard13(Path.GetFileNameWithoutExtension(analyzerFileName)));
var srcFile = analyzerDir.CreateFile(srcFileName).WriteAllText("public class C { }");

Expand All @@ -11123,6 +11125,7 @@ at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_N
Assert.Equal(0, result.ExitCode);
}
#endif

[WorkItem(406649, "https://devdiv.visualstudio.com/DevDiv/_workitems?id=484417")]
[ConditionalFact(typeof(WindowsDesktopOnly), typeof(IsEnglishLocal), Reason = "https://github.com/dotnet/roslyn/issues/30321")]
public void MicrosoftDiaSymReaderNativeAltLoadPath()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Linq;
using System.Runtime.InteropServices;
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
using Microsoft.CodeAnalysis.Test.Resources.Proprietary;
using Microsoft.CodeAnalysis.Test.Utilities;
using Roslyn.Test.Utilities;
using Xunit;
Expand Down Expand Up @@ -74,7 +75,7 @@ public void AppConfigCsc()
</runtime>
</configuration>").Path;

var silverlight = Temp.CreateFile().WriteAllBytes(TestResources.NetFX.silverlight_v5_0_5_0.System_v5_0_5_0_silverlight).Path;
var silverlight = Temp.CreateFile().WriteAllBytes(ProprietaryTestResources.silverlight_v5_0_5_0.System_v5_0_5_0_silverlight).Path;
var net4_0dll = Temp.CreateFile().WriteAllBytes(ResourcesNet451.System).Path;

var outWriter = new StringWriter(CultureInfo.InvariantCulture);
Expand Down
3 changes: 2 additions & 1 deletion src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
using Microsoft.CodeAnalysis.Emit;
using Microsoft.CodeAnalysis.Test.Resources.Proprietary;
using Microsoft.CodeAnalysis.Test.Utilities;
using Roslyn.Test.Utilities;
using Xunit;
Expand Down Expand Up @@ -15102,7 +15103,7 @@ static void Main()
}
}";

var testReference = AssemblyMetadata.CreateFromImage(TestResources.Repros.BadDefaultParameterValue).GetReference();
var testReference = AssemblyMetadata.CreateFromImage(ProprietaryTestResources.Repros.BadDefaultParameterValue).GetReference();
var compilation = CompileAndVerify(source, references: new[] { testReference });
compilation.VerifyIL("Program.Main", @"
{
Expand Down
3 changes: 2 additions & 1 deletion src/Compilers/CSharp/Test/WinRT/Metadata/WinMdDumpTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE;
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
using Microsoft.CodeAnalysis.Test.Resources.Proprietary;
using Microsoft.CodeAnalysis.Test.Utilities;
using Roslyn.Test.Utilities;
using Roslyn.Utilities;
Expand All @@ -23,7 +24,7 @@ public class WinMdDumpTest : CSharpTestBase
private readonly MetadataReference _windowsRef = MetadataReference.CreateFromImage(TestResources.WinRt.Windows.AsImmutableOrNull());
private readonly MetadataReference _systemRuntimeRef = MetadataReference.CreateFromImage(TestMetadata.ResourcesNet451.SystemRuntime.AsImmutableOrNull());
private readonly MetadataReference _systemObjectModelRef = MetadataReference.CreateFromImage(TestMetadata.ResourcesNet451.SystemObjectModel.AsImmutableOrNull());
private readonly MetadataReference _windowsRuntimeUIXamlRef = MetadataReference.CreateFromImage(TestResources.NetFX.v4_0_30319_17929.System_Runtime_WindowsRuntime_UI_Xaml.AsImmutableOrNull());
private readonly MetadataReference _windowsRuntimeUIXamlRef = MetadataReference.CreateFromImage(ProprietaryTestResources.v4_0_30319_17929.System_Runtime_WindowsRuntime_UI_Xaml.AsImmutableOrNull());
private readonly MetadataReference _interopServicesWindowsRuntimeRef = MetadataReference.CreateFromImage(TestMetadata.ResourcesNet451.SystemRuntimeInteropServicesWindowsRuntime.AsImmutableOrNull());

private void AppendMembers(StringBuilder result, NamespaceOrTypeSymbol container, string indent)
Expand Down
3 changes: 2 additions & 1 deletion src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTests.vb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Imports System.Collections.Immutable
Imports System.Reflection
Imports System.Xml.Linq
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Test.Resources.Proprietary
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Expand Down Expand Up @@ -13504,7 +13505,7 @@ End Module
</file>
</compilation>

Dim testReference = AssemblyMetadata.CreateFromImage(TestResources.Repros.BadDefaultParameterValue).GetReference()
Dim testReference = AssemblyMetadata.CreateFromImage(ProprietaryTestResources.Repros.BadDefaultParameterValue).GetReference()
Dim compilation = CompileAndVerify(source, references:=New MetadataReference() {testReference})
compilation.VerifyIL("C.Main",
<![CDATA[
Expand Down
7 changes: 4 additions & 3 deletions src/Test/Utilities/Portable/Mocks/TestReferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.IO;
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Test.Resources.Proprietary;
using Roslyn.Test.Utilities;

public static class TestReferences
Expand Down Expand Up @@ -95,7 +96,7 @@ public static class ValueTuple
public static class silverlight_v5_0_5_0
{
private static readonly Lazy<PortableExecutableReference> s_system = new Lazy<PortableExecutableReference>(
() => AssemblyMetadata.CreateFromImage(TestResources.NetFX.silverlight_v5_0_5_0.System_v5_0_5_0_silverlight).GetReference(display: "System.v5.0.5.0_silverlight.dll"),
() => AssemblyMetadata.CreateFromImage(ProprietaryTestResources.silverlight_v5_0_5_0.System_v5_0_5_0_silverlight).GetReference(display: "System.v5.0.5.0_silverlight.dll"),
LazyThreadSafetyMode.PublicationOnly);
public static PortableExecutableReference System => s_system.Value;
}
Expand All @@ -104,7 +105,7 @@ public static class silverlight_v5_0_5_0
public static class NetStandard13
{
private static readonly Lazy<PortableExecutableReference> s_systemRuntime = new Lazy<PortableExecutableReference>(
() => AssemblyMetadata.CreateFromImage(TestResources.NetFX.netstandard13.System_Runtime).GetReference(display: @"System.Runtime.dll (netstandard13 ref)"),
() => AssemblyMetadata.CreateFromImage(ProprietaryTestResources.netstandard13.System_Runtime).GetReference(display: @"System.Runtime.dll (netstandard13 ref)"),
LazyThreadSafetyMode.PublicationOnly);
public static PortableExecutableReference SystemRuntime => s_systemRuntime.Value;
}
Expand Down Expand Up @@ -694,7 +695,7 @@ public static class MultiTargeting
public static class NoPia
{
private static readonly Lazy<PortableExecutableReference> s_stdOle = new Lazy<PortableExecutableReference>(
() => AssemblyMetadata.CreateFromImage(TestResources.ProprietaryPias.stdole).GetReference(display: "stdole.dll"),
() => AssemblyMetadata.CreateFromImage(ProprietaryTestResources.ProprietaryPias.stdole).GetReference(display: "stdole.dll"),
LazyThreadSafetyMode.PublicationOnly);
public static PortableExecutableReference StdOle => s_stdOle.Value;

Expand Down
75 changes: 38 additions & 37 deletions src/Test/Utilities/Portable/Platform/Desktop/TestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Test.Resources.Proprietary;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.Win32;

Expand Down Expand Up @@ -139,7 +140,7 @@ public sealed class DiagnosticDescriptor
var minSystemCollectionsImmutableImage = CSharpCompilation.Create(
"System.Collections.Immutable",
new[] { SyntaxFactory.ParseSyntaxTree(minSystemCollectionsImmutableSource) },
new[] { MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Runtime) },
new[] { MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Runtime) },
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, cryptoPublicKey: TestResources.TestKeys.PublicKey_b03f5f7f11d50a3a)).EmitToArray();

var minSystemCollectionsImmutableRef = MetadataReference.CreateFromImage(minSystemCollectionsImmutableImage);
Expand All @@ -149,7 +150,7 @@ public sealed class DiagnosticDescriptor
new[] { SyntaxFactory.ParseSyntaxTree(minCodeAnalysisSource) },
new[]
{
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Runtime),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Runtime),
minSystemCollectionsImmutableRef
},
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, cryptoPublicKey: TestResources.TestKeys.PublicKey_31bf3856ad364e35)).EmitToArray();
Expand Down Expand Up @@ -241,41 +242,41 @@ public override void Initialize(AnalysisContext context)
{
minCodeAnalysisRef,
minSystemCollectionsImmutableRef,
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.Microsoft_Win32_Primitives),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_AppContext),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Console),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_ValueTuple),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Diagnostics_FileVersionInfo),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Diagnostics_Process),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Diagnostics_StackTrace),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Globalization_Calendars),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_IO_Compression),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_IO_Compression_ZipFile),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_IO_FileSystem),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_IO_FileSystem_Primitives),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_IO_Pipes),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Net_Http),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Net_Security),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Net_Sockets),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Reflection_TypeExtensions),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Runtime),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Runtime_InteropServices_RuntimeInformation),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Runtime_Serialization_Primitives),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Security_AccessControl),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Security_Claims),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Security_Cryptography_Algorithms),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Security_Cryptography_Csp),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Security_Cryptography_Encoding),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Security_Cryptography_Primitives),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Security_Cryptography_X509Certificates),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Security_Principal_Windows),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Threading_Thread),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Threading_Tasks_Extensions),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Xml_ReaderWriter),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Xml_XmlDocument),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Xml_XPath),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Xml_XPath_XDocument),
MetadataReference.CreateFromImage(TestResources.NetFX.netstandard13.System_Text_Encoding_CodePages)
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.Microsoft_Win32_Primitives),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_AppContext),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Console),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_ValueTuple),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Diagnostics_FileVersionInfo),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Diagnostics_Process),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Diagnostics_StackTrace),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Globalization_Calendars),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_IO_Compression),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_IO_Compression_ZipFile),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_IO_FileSystem),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_IO_FileSystem_Primitives),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_IO_Pipes),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Net_Http),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Net_Security),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Net_Sockets),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Reflection_TypeExtensions),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Runtime),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Runtime_InteropServices_RuntimeInformation),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Runtime_Serialization_Primitives),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Security_AccessControl),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Security_Claims),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Security_Cryptography_Algorithms),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Security_Cryptography_Csp),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Security_Cryptography_Encoding),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Security_Cryptography_Primitives),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Security_Cryptography_X509Certificates),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Security_Principal_Windows),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Threading_Thread),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Threading_Tasks_Extensions),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Xml_ReaderWriter),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Xml_XmlDocument),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Xml_XPath),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Xml_XPath_XDocument),
MetadataReference.CreateFromImage(ProprietaryTestResources.netstandard13.System_Text_Encoding_CodePages)
},
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)).EmitToArray();

Expand Down
Loading

0 comments on commit b3f5c67

Please sign in to comment.