diff --git a/DllImportGenerator/Directory.Build.props b/DllImportGenerator/Directory.Build.props
new file mode 100644
index 000000000000..22565674b76a
--- /dev/null
+++ b/DllImportGenerator/Directory.Build.props
@@ -0,0 +1,13 @@
+
+
+
+ Microsoft
+ https://github.com/dotnet/runtimelab/tree/feature/DllImportGenerator
+ https://github.com/dotnet/runtimelab/tree/feature/DllImportGenerator
+ false
+ DllImportGenerator
+ Summary of changes made in this release of the package.
+ Copyright
+ DllImportGenerator, analyzers
+
+
\ No newline at end of file
diff --git a/DllImportGenerator/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs b/DllImportGenerator/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs
index 2df44242463e..061205bb3f68 100644
--- a/DllImportGenerator/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs
+++ b/DllImportGenerator/DllImportGenerator/Analyzers/ConvertToGeneratedDllImportAnalyzer.cs
@@ -4,7 +4,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
-
+using Microsoft.Interop.SourceGeneration;
using static Microsoft.Interop.Analyzers.AnalyzerDiagnostics;
namespace Microsoft.Interop.Analyzers
diff --git a/DllImportGenerator/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs b/DllImportGenerator/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs
index 3bedc018cf58..9f4146492583 100644
--- a/DllImportGenerator/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs
+++ b/DllImportGenerator/DllImportGenerator/Analyzers/GeneratedDllImportAnalyzer.cs
@@ -5,7 +5,7 @@
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
-
+using Microsoft.Interop.SourceGeneration;
using static Microsoft.Interop.Analyzers.AnalyzerDiagnostics;
namespace Microsoft.Interop.Analyzers
diff --git a/DllImportGenerator/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs b/DllImportGenerator/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs
index 97bc59387711..f618742ed9bf 100644
--- a/DllImportGenerator/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs
+++ b/DllImportGenerator/DllImportGenerator/Analyzers/ManualTypeMarshallingAnalyzer.cs
@@ -4,7 +4,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
-
+using Microsoft.Interop.SourceGeneration;
using static Microsoft.Interop.Analyzers.AnalyzerDiagnostics;
namespace Microsoft.Interop.Analyzers
diff --git a/DllImportGenerator/DllImportGenerator/DllImportGenerator.csproj b/DllImportGenerator/DllImportGenerator/DllImportGenerator.csproj
index c0c8bc14dbc4..3409e73485e4 100644
--- a/DllImportGenerator/DllImportGenerator/DllImportGenerator.csproj
+++ b/DllImportGenerator/DllImportGenerator/DllImportGenerator.csproj
@@ -9,18 +9,7 @@
true
Preview
enable
- Microsoft.Interop
-
-
-
- Microsoft
- https://github.com/dotnet/runtimelab/tree/feature/DllImportGenerator
- https://github.com/dotnet/runtimelab/tree/feature/DllImportGenerator
- false
- DllImportGenerator
- Summary of changes made in this release of the package.
- Copyright
- DllImportGenerator, analyzers
+ Microsoft.Interop.DllImportGenerator
true
@@ -39,7 +28,8 @@
-
+
@@ -56,15 +46,4 @@
Resources.Designer.cs
-
-
-
-
-
-
-
-
-
-
-
diff --git a/DllImportGenerator/DllImportGenerator/DllImportStub.cs b/DllImportGenerator/DllImportGenerator/DllImportStub.cs
index ba336d36ed41..789e9a5308f6 100644
--- a/DllImportGenerator/DllImportGenerator/DllImportStub.cs
+++ b/DllImportGenerator/DllImportGenerator/DllImportStub.cs
@@ -7,6 +7,7 @@
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.Interop.SourceGeneration;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
namespace Microsoft.Interop
diff --git a/DllImportGenerator/DllImportGenerator/ForwarderMarshallingGeneratorFactory.cs b/DllImportGenerator/DllImportGenerator/ForwarderMarshallingGeneratorFactory.cs
index 60c85b4baba0..d6261c6fa464 100644
--- a/DllImportGenerator/DllImportGenerator/ForwarderMarshallingGeneratorFactory.cs
+++ b/DllImportGenerator/DllImportGenerator/ForwarderMarshallingGeneratorFactory.cs
@@ -1,4 +1,5 @@
-using System;
+using Microsoft.Interop.SourceGeneration;
+using System;
using System.Collections.Generic;
using System.Text;
diff --git a/DllImportGenerator/DllImportGenerator/GeneratorDiagnostics.cs b/DllImportGenerator/DllImportGenerator/GeneratorDiagnostics.cs
index 6a103ccc71d4..73e674450514 100644
--- a/DllImportGenerator/DllImportGenerator/GeneratorDiagnostics.cs
+++ b/DllImportGenerator/DllImportGenerator/GeneratorDiagnostics.cs
@@ -1,4 +1,5 @@
using Microsoft.CodeAnalysis;
+using Microsoft.Interop.SourceGeneration;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -6,11 +7,10 @@
namespace Microsoft.Interop
{
-
///
/// Class for reporting diagnostics in the DLL import generator
///
- public class GeneratorDiagnostics : IGeneratorDiagnostics
+ internal class GeneratorDiagnostics : IGeneratorDiagnostics
{
public class Ids
{
diff --git a/DllImportGenerator/DllImportGenerator/LanguageSupport.cs b/DllImportGenerator/DllImportGenerator/LanguageSupport.cs
deleted file mode 100644
index ddf2c4203111..000000000000
--- a/DllImportGenerator/DllImportGenerator/LanguageSupport.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-// Types defined to enable language support of various features
-// in the source generator.
-
-
-namespace System.Runtime.CompilerServices
-{
- // Define IsExternalInit type to support records.
- internal class IsExternalInit
- {}
-}
\ No newline at end of file
diff --git a/DllImportGenerator/DllImportGenerator/NoPreserveSigMarshallingGeneratorFactory.cs b/DllImportGenerator/DllImportGenerator/NoPreserveSigMarshallingGeneratorFactory.cs
index d0ed18a3520a..9c771a5f39fc 100644
--- a/DllImportGenerator/DllImportGenerator/NoPreserveSigMarshallingGeneratorFactory.cs
+++ b/DllImportGenerator/DllImportGenerator/NoPreserveSigMarshallingGeneratorFactory.cs
@@ -1,5 +1,6 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.Interop.SourceGeneration;
using System;
using System.Collections.Generic;
using System.Text;
diff --git a/DllImportGenerator/DllImportGenerator/PInvokeStubCodeGenerator.cs b/DllImportGenerator/DllImportGenerator/PInvokeStubCodeGenerator.cs
index 3bc4db993535..d22e40197cbf 100644
--- a/DllImportGenerator/DllImportGenerator/PInvokeStubCodeGenerator.cs
+++ b/DllImportGenerator/DllImportGenerator/PInvokeStubCodeGenerator.cs
@@ -6,6 +6,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.Interop.SourceGeneration;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
namespace Microsoft.Interop
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/ArrayMarshallingCodeContext.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/ArrayMarshallingCodeContext.cs
index 9e8d1ab5a200..2b581ee77414 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/ArrayMarshallingCodeContext.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/ArrayMarshallingCodeContext.cs
@@ -8,7 +8,7 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
internal sealed class ArrayMarshallingCodeContext : StubCodeContext
{
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/IGeneratorDiagnostics.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/IGeneratorDiagnostics.cs
index fb01f60070d2..7a3e830e8311 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/IGeneratorDiagnostics.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/IGeneratorDiagnostics.cs
@@ -5,9 +5,9 @@
using Microsoft.CodeAnalysis;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
- public static class DiagnosticExtensions
+ internal static class DiagnosticExtensions
{
public static Diagnostic CreateDiagnostic(
this ISymbol symbol,
@@ -42,7 +42,7 @@ public static Diagnostic CreateDiagnostic(
}
}
- public interface IGeneratorDiagnostics
+ internal interface IGeneratorDiagnostics
{
///
/// Report diagnostic for marshalling of a parameter/return that is not supported
@@ -67,7 +67,7 @@ void ReportConfigurationNotSupported(
string? unsupportedValue);
}
- public static class IGeneratorDiagnosticsExtensions
+ internal static class IGeneratorDiagnosticsExtensions
{
public static void ReportConfigurationNotSupported(this IGeneratorDiagnostics diagnostics, AttributeData attributeData, string configurationName)
=> diagnostics.ReportConfigurationNotSupported(attributeData, configurationName, null);
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/InteropGenerationOptions.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/InteropGenerationOptions.cs
index d65ea4cb67ee..014dacec09a6 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/InteropGenerationOptions.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/InteropGenerationOptions.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
- public record InteropGenerationOptions(bool UseMarshalType);
+ internal record InteropGenerationOptions(bool UseMarshalType);
}
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs
index 7f86b833665c..bb8e3a5a6c23 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs
@@ -2,9 +2,9 @@
using System.Linq;
using Microsoft.CodeAnalysis;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
- public static class ManualTypeMarshallingHelper
+ internal static class ManualTypeMarshallingHelper
{
public const string ValuePropertyName = "Value";
public const string GetPinnableReferenceName = "GetPinnableReference";
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/BlittableArrayMarshaller.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/BlittableArrayMarshaller.cs
index a1bba95c3932..57127a1d7c57 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/BlittableArrayMarshaller.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/BlittableArrayMarshaller.cs
@@ -5,9 +5,9 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
- public sealed class BlittableArrayMarshaller : ConditionalStackallocMarshallingGenerator
+ internal sealed class BlittableArrayMarshaller : ConditionalStackallocMarshallingGenerator
{
///
/// Stack-alloc threshold set to 256 bytes to enable small arrays to be passed on the stack.
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs
index 817734c0d38f..551653e6b488 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs
@@ -5,9 +5,9 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
- public sealed class BlittableMarshaller : IMarshallingGenerator
+ internal sealed class BlittableMarshaller : IMarshallingGenerator
{
public TypeSyntax AsNativeType(TypePositionInfo info)
{
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs
index b20bf1e2e4ed..3ae9be4458a8 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs
@@ -6,9 +6,9 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
- public abstract class BoolMarshallerBase : IMarshallingGenerator
+ internal abstract class BoolMarshallerBase : IMarshallingGenerator
{
private readonly PredefinedTypeSyntax _nativeType;
private readonly int _trueValue;
@@ -114,7 +114,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont
/// and C++, but those is implementation defined.
/// Consult your compiler specification.
///
- public sealed class ByteBoolMarshaller : BoolMarshallerBase
+ internal sealed class ByteBoolMarshaller : BoolMarshallerBase
{
public ByteBoolMarshaller()
: base(PredefinedType(Token(SyntaxKind.ByteKeyword)), trueValue: 1, falseValue: 0, compareToTrue: false)
@@ -128,7 +128,7 @@ public ByteBoolMarshaller()
///
/// Corresponds to the definition of BOOL.
///
- public sealed class WinBoolMarshaller : BoolMarshallerBase
+ internal sealed class WinBoolMarshaller : BoolMarshallerBase
{
public WinBoolMarshaller()
: base(PredefinedType(Token(SyntaxKind.IntKeyword)), trueValue: 1, falseValue: 0, compareToTrue: false)
@@ -139,7 +139,7 @@ public WinBoolMarshaller()
///
/// Marshal a boolean value as a VARIANT_BOOL (Windows OLE/Automation type).
///
- public sealed class VariantBoolMarshaller : BoolMarshallerBase
+ internal sealed class VariantBoolMarshaller : BoolMarshallerBase
{
private const short VARIANT_TRUE = -1;
private const short VARIANT_FALSE = 0;
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs
index ba193ce4d802..ed43faac3f51 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs
@@ -7,9 +7,9 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
- public sealed class Utf16CharMarshaller : IMarshallingGenerator
+ internal sealed class Utf16CharMarshaller : IMarshallingGenerator
{
private static readonly PredefinedTypeSyntax NativeType = PredefinedType(Token(SyntaxKind.UShortKeyword));
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/ConditionalStackallocMarshallingGenerator.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/ConditionalStackallocMarshallingGenerator.cs
index f0bde9de1903..034322b1f6b9 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/ConditionalStackallocMarshallingGenerator.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/ConditionalStackallocMarshallingGenerator.cs
@@ -4,9 +4,9 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
- public abstract class ConditionalStackallocMarshallingGenerator : IMarshallingGenerator
+ internal abstract class ConditionalStackallocMarshallingGenerator : IMarshallingGenerator
{
protected static string GetAllocationMarkerIdentifier(string managedIdentifier) => $"{managedIdentifier}__allocated";
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/CustomNativeTypeMarshaller.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/CustomNativeTypeMarshaller.cs
index 155ad5e7a9bd..b3f0e5ce8996 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/CustomNativeTypeMarshaller.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/CustomNativeTypeMarshaller.cs
@@ -6,9 +6,9 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
- public sealed class CustomNativeTypeMarshaller : IMarshallingGenerator
+ internal sealed class CustomNativeTypeMarshaller : IMarshallingGenerator
{
private const string MarshalerLocalSuffix = "__marshaler";
private readonly TypeSyntax _nativeTypeSyntax;
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs
index 45432ec384cf..ee30df792973 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs
@@ -4,9 +4,9 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
- public sealed class DelegateMarshaller : IMarshallingGenerator
+ internal sealed class DelegateMarshaller : IMarshallingGenerator
{
public TypeSyntax AsNativeType(TypePositionInfo info)
{
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs
index 34c9c7119f06..31bf925be2e1 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs
@@ -4,9 +4,9 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
- public sealed class Forwarder : IMarshallingGenerator
+ internal sealed class Forwarder : IMarshallingGenerator
{
public TypeSyntax AsNativeType(TypePositionInfo info)
{
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/HResultExceptionMarshaller.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/HResultExceptionMarshaller.cs
index 360d2b26216e..3d6994c2ee77 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/HResultExceptionMarshaller.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/HResultExceptionMarshaller.cs
@@ -7,9 +7,9 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
- public sealed class HResultExceptionMarshaller : IMarshallingGenerator
+ internal sealed class HResultExceptionMarshaller : IMarshallingGenerator
{
private static readonly TypeSyntax NativeType = PredefinedType(Token(SyntaxKind.IntKeyword));
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs
index e4145d3e9bb8..30361975a20a 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs
@@ -3,9 +3,9 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
- public static class MarshallerHelpers
+ internal static class MarshallerHelpers
{
public static readonly ExpressionSyntax IsWindows = InvocationExpression(
MemberAccessExpression(
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs
index 63653d2884ce..b2205f2136ec 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs
@@ -3,12 +3,12 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
///
/// Interface for generation of marshalling code for P/Invoke stubs
///
- public interface IMarshallingGenerator
+ internal interface IMarshallingGenerator
{
///
/// Get the native type syntax for
@@ -71,7 +71,7 @@ public interface IMarshallingGenerator
///
/// Exception used to indicate marshalling isn't supported.
///
- public sealed class MarshallingNotSupportedException : Exception
+ internal sealed class MarshallingNotSupportedException : Exception
{
///
/// Construct a new instance.
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs
index fa6b66a1d966..2576edc57273 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorFactory.cs
@@ -5,9 +5,9 @@
using Microsoft.CodeAnalysis.Diagnostics;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
- public interface IMarshallingGeneratorFactory
+ internal interface IMarshallingGeneratorFactory
{
///
/// Create an instance for marshalling the supplied type in the given position.
@@ -20,7 +20,7 @@ public IMarshallingGenerator Create(
StubCodeContext context);
}
- public sealed class DefaultMarshallingGeneratorFactory : IMarshallingGeneratorFactory
+ internal sealed class DefaultMarshallingGeneratorFactory : IMarshallingGeneratorFactory
{
private static readonly ByteBoolMarshaller ByteBool = new();
private static readonly WinBoolMarshaller WinBool = new();
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/NonBlittableArrayMarshaller.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/NonBlittableArrayMarshaller.cs
index 9c1755ab9341..70136cd85d5a 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/NonBlittableArrayMarshaller.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/NonBlittableArrayMarshaller.cs
@@ -6,9 +6,9 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
- public sealed class NonBlittableArrayMarshaller : ConditionalStackallocMarshallingGenerator
+ internal sealed class NonBlittableArrayMarshaller : ConditionalStackallocMarshallingGenerator
{
///
/// Stack-alloc threshold set to 256 bytes to enable small arrays to be passed on the stack.
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs
index b4536cbcfe39..54d2100b42f5 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs
@@ -6,9 +6,9 @@
using Microsoft.CodeAnalysis.Diagnostics;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
- public sealed class SafeHandleMarshaller : IMarshallingGenerator
+ internal sealed class SafeHandleMarshaller : IMarshallingGenerator
{
private static readonly TypeSyntax NativeType = ParseTypeName("global::System.IntPtr");
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs
index 16e1f026606d..7edc11aba2d0 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Ansi.cs
@@ -5,11 +5,11 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-using static Microsoft.Interop.MarshallerHelpers;
+using static Microsoft.Interop.SourceGeneration.MarshallerHelpers;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
- public sealed class AnsiStringMarshaller : ConditionalStackallocMarshallingGenerator
+ internal sealed class AnsiStringMarshaller : ConditionalStackallocMarshallingGenerator
{
private static readonly TypeSyntax NativeType = PointerType(PredefinedType(Token(SyntaxKind.ByteKeyword)));
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.PlatformDefined.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.PlatformDefined.cs
index 3de4c48a724b..02ee37d53c91 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.PlatformDefined.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.PlatformDefined.cs
@@ -6,11 +6,11 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-using static Microsoft.Interop.MarshallerHelpers;
+using static Microsoft.Interop.SourceGeneration.MarshallerHelpers;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
- public sealed class PlatformDefinedStringMarshaller : ConditionalStackallocMarshallingGenerator
+ internal sealed class PlatformDefinedStringMarshaller : ConditionalStackallocMarshallingGenerator
{
private static readonly TypeSyntax NativeType = PointerType(PredefinedType(Token(SyntaxKind.VoidKeyword)));
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs
index 9623967cf6e4..38b77525c3d1 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf16.cs
@@ -4,11 +4,11 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-using static Microsoft.Interop.MarshallerHelpers;
+using static Microsoft.Interop.SourceGeneration.MarshallerHelpers;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
- public sealed class Utf16StringMarshaller : ConditionalStackallocMarshallingGenerator
+ internal sealed class Utf16StringMarshaller : ConditionalStackallocMarshallingGenerator
{
// [Compat] Equivalent of MAX_PATH on Windows to match built-in system
// The assumption is file paths are the most common case for marshalling strings,
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs
index 2a4801e8d3c3..c082cccbefea 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.cs
@@ -4,11 +4,11 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-using static Microsoft.Interop.MarshallerHelpers;
+using static Microsoft.Interop.SourceGeneration.MarshallerHelpers;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
- public sealed class Utf8StringMarshaller : ConditionalStackallocMarshallingGenerator
+ internal sealed class Utf8StringMarshaller : ConditionalStackallocMarshallingGenerator
{
// [Compat] Equivalent of MAX_PATH on Windows to match built-in system
// The assumption is file paths are the most common case for marshalling strings,
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs
index 88c378919ea0..7a7790d5be54 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs
@@ -4,21 +4,17 @@
using System.Diagnostics;
using System.Runtime.InteropServices;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
// The following types are modeled to fit with the current prospective spec
// for C# 10 discriminated unions. Once discriminated unions are released,
// these should be updated to be implemented as a discriminated union.
- public abstract record MarshallingInfo
+ internal abstract record MarshallingInfo
{
- // Add a constructor that can only be called by derived types in the same assembly
- // to enforce that this type cannot be extended by users of this library.
- private protected MarshallingInfo()
- {}
}
- public sealed record NoMarshallingInfo : MarshallingInfo
+ internal sealed record NoMarshallingInfo : MarshallingInfo
{
public static readonly MarshallingInfo Instance = new NoMarshallingInfo();
@@ -28,7 +24,7 @@ private NoMarshallingInfo() { }
///
/// Character encoding enumeration.
///
- public enum CharEncoding
+ internal enum CharEncoding
{
Undefined,
Utf8,
@@ -40,20 +36,20 @@ public enum CharEncoding
///
/// Details that are required when scenario supports strings.
///
- public record MarshallingInfoStringSupport(
+ internal record MarshallingInfoStringSupport(
CharEncoding CharEncoding
) : MarshallingInfo;
///
/// Simple User-application of System.Runtime.InteropServices.MarshalAsAttribute
///
- public record MarshalAsInfo(
+ internal record MarshalAsInfo(
UnmanagedType UnmanagedType,
CharEncoding CharEncoding) : MarshallingInfoStringSupport(CharEncoding)
{
}
- public enum UnmanagedArrayType
+ internal enum UnmanagedArrayType
{
LPArray = UnmanagedType.LPArray,
ByValArray = UnmanagedType.ByValArray
@@ -62,7 +58,7 @@ public enum UnmanagedArrayType
///
/// User-applied System.Runtime.InteropServices.MarshalAsAttribute with array marshalling info
///
- public sealed record ArrayMarshalAsInfo(
+ internal sealed record ArrayMarshalAsInfo(
UnmanagedArrayType UnmanagedArrayType,
int ArraySizeConst,
short ArraySizeParamIndex,
@@ -77,10 +73,10 @@ public sealed record ArrayMarshalAsInfo(
/// or System.Runtime.InteropServices.GeneratedMarshallingAttribute on a blittable type
/// in source in this compilation.
///
- public sealed record BlittableTypeAttributeInfo : MarshallingInfo;
+ internal sealed record BlittableTypeAttributeInfo : MarshallingInfo;
[Flags]
- public enum SupportedMarshallingMethods
+ internal enum SupportedMarshallingMethods
{
ManagedToNative = 0x1,
NativeToManaged = 0x2,
@@ -91,7 +87,7 @@ public enum SupportedMarshallingMethods
///
/// User-applied System.Runtime.InteropServices.NativeMarshallingAttribute
///
- public sealed record NativeMarshallingAttributeInfo(
+ internal sealed record NativeMarshallingAttributeInfo(
ITypeSymbol NativeMarshallingType,
ITypeSymbol? ValuePropertyType,
SupportedMarshallingMethods MarshallingMethods,
@@ -101,17 +97,17 @@ public sealed record NativeMarshallingAttributeInfo(
/// User-applied System.Runtime.InteropServices.GeneratedMarshallingAttribute
/// on a non-blittable type in source in this compilation.
///
- public sealed record GeneratedNativeMarshallingAttributeInfo(
+ internal sealed record GeneratedNativeMarshallingAttributeInfo(
string NativeMarshallingFullyQualifiedTypeName) : MarshallingInfo;
///
/// The type of the element is a SafeHandle-derived type with no marshalling attributes.
///
- public sealed record SafeHandleMarshallingInfo(bool AccessibleDefaultConstructor) : MarshallingInfo;
+ internal sealed record SafeHandleMarshallingInfo(bool AccessibleDefaultConstructor) : MarshallingInfo;
///
/// Default marshalling for arrays
///
- public sealed record ArrayMarshallingInfo(MarshallingInfo ElementMarshallingInfo) : MarshallingInfo;
+ internal sealed record ArrayMarshallingInfo(MarshallingInfo ElementMarshallingInfo) : MarshallingInfo;
}
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj
index 703bce87fd4f..159264372579 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj
@@ -2,13 +2,15 @@
netstandard2.0
- false
enable
- Microsoft.Interop
+ Microsoft.Interop.SourceGeneration
+ false
+ True
+ true
-
+
@@ -17,13 +19,13 @@
True
True
-
-
-
Designer
Resources.Designer.cs
ResXFileCodeGenerator
+ Microsoft.Interop.SourceGenerationResources
+
+
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Resources.Designer.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Resources.Designer.cs
index c451a2bece59..90121a74e5a1 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Resources.Designer.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Resources.Designer.cs
@@ -8,7 +8,7 @@
//
//------------------------------------------------------------------------------
-namespace Microsoft.Interop {
+namespace Microsoft.Interop.SourceGeneration {
using System;
@@ -39,7 +39,7 @@ internal Resources() {
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Interop.Resources", typeof(Resources).Assembly);
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Interop.SourceGeneration.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
@@ -213,6 +213,15 @@ internal static string SafeHandleByRefMustBeConcrete {
}
}
+ ///
+ /// Looks up a localized string similar to .
+ ///
+ internal static string Test {
+ get {
+ return ResourceManager.GetString("Test", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Specified type is not supported by source-generated P/Invokes.
///
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Resources.resx b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Resources.resx
index d21ad29d3da4..bf9eeca37c4f 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/Resources.resx
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/Resources.resx
@@ -168,6 +168,9 @@
An abstract type derived from 'SafeHandle' cannot be marshalled by reference. The provided type must be concrete.
+
+
+
Specified type is not supported by source-generated P/Invokes
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/StubCodeContext.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/StubCodeContext.cs
index 9b212d35735e..e6a2b6511480 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/StubCodeContext.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/StubCodeContext.cs
@@ -1,8 +1,8 @@
using System;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
- public abstract class StubCodeContext
+ internal abstract class StubCodeContext
{
///
/// Code generation stage
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/TypeNames.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/TypeNames.cs
index 1a640a2c395e..d4b1f1d9d54c 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/TypeNames.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/TypeNames.cs
@@ -4,7 +4,7 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.Interop;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
static class TypeNames
{
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs
index 79ae33ec11f4..60a8de4bb073 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs
@@ -7,12 +7,12 @@
using Microsoft.CodeAnalysis.CSharp;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
///
/// Type used to pass on default marshalling details.
///
- public sealed record DefaultMarshallingInfo (
+ internal sealed record DefaultMarshallingInfo (
CharEncoding CharEncoding
);
@@ -23,7 +23,7 @@ CharEncoding CharEncoding
/// contents of the managed array.
///
[Flags]
- public enum ByValueContentsMarshalKind
+ internal enum ByValueContentsMarshalKind
{
///
/// Marshal contents from managed to native only.
@@ -48,7 +48,7 @@ public enum ByValueContentsMarshalKind
///
/// Positional type information involved in unmanaged/managed scenarios.
///
- public sealed record TypePositionInfo
+ internal sealed record TypePositionInfo
{
public const int UnsetIndex = int.MinValue;
public const int ReturnIndex = UnsetIndex + 1;
diff --git a/DllImportGenerator/Microsoft.Interop.SourceGeneration/TypeSymbolExtensions.cs b/DllImportGenerator/Microsoft.Interop.SourceGeneration/TypeSymbolExtensions.cs
index 92ae1214e31a..249471e3ca03 100644
--- a/DllImportGenerator/Microsoft.Interop.SourceGeneration/TypeSymbolExtensions.cs
+++ b/DllImportGenerator/Microsoft.Interop.SourceGeneration/TypeSymbolExtensions.cs
@@ -9,9 +9,9 @@
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
-namespace Microsoft.Interop
+namespace Microsoft.Interop.SourceGeneration
{
- public static class TypeSymbolExtensions
+ internal static class TypeSymbolExtensions
{
public static bool HasOnlyBlittableFields(this ITypeSymbol type)
{