Skip to content

Commit

Permalink
Convert Microsoft.Interop.SourceGeneration to a source package.
Browse files Browse the repository at this point in the history
  • Loading branch information
jkoritzinsky committed May 17, 2021
1 parent 3d2b9dc commit 7e53797
Show file tree
Hide file tree
Showing 41 changed files with 119 additions and 122 deletions.
13 changes: 13 additions & 0 deletions DllImportGenerator/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props, $(MSBuildThisFileDirectory)..))" />
<PropertyGroup>
<Authors>Microsoft</Authors>
<PackageProjectUrl>https://github.com/dotnet/runtimelab/tree/feature/DllImportGenerator</PackageProjectUrl>
<RepositoryUrl>https://github.com/dotnet/runtimelab/tree/feature/DllImportGenerator</RepositoryUrl>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Description>DllImportGenerator</Description>
<PackageReleaseNotes>Summary of changes made in this release of the package.</PackageReleaseNotes>
<Copyright>Copyright</Copyright>
<PackageTags>DllImportGenerator, analyzers</PackageTags>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 3 additions & 24 deletions DllImportGenerator/DllImportGenerator/DllImportGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>Preview</LangVersion>
<Nullable>enable</Nullable>
<RootNamespace>Microsoft.Interop</RootNamespace>
</PropertyGroup>

<PropertyGroup>
<Authors>Microsoft</Authors>
<PackageProjectUrl>https://github.com/dotnet/runtimelab/tree/feature/DllImportGenerator</PackageProjectUrl>
<RepositoryUrl>https://github.com/dotnet/runtimelab/tree/feature/DllImportGenerator</RepositoryUrl>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Description>DllImportGenerator</Description>
<PackageReleaseNotes>Summary of changes made in this release of the package.</PackageReleaseNotes>
<Copyright>Copyright</Copyright>
<PackageTags>DllImportGenerator, analyzers</PackageTags>
<RootNamespace>Microsoft.Interop.DllImportGenerator</RootNamespace>
<NoPackageAnalysis>true</NoPackageAnalysis>
</PropertyGroup>

Expand All @@ -39,7 +28,8 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj" />
<Compile Include="../Microsoft.Interop.SourceGeneration/**/*.cs"
Link="Microsoft.Interop.SourceGeneration/%(RecursiveDir)%(FileName)%(Extension)" />
</ItemGroup>

<ItemGroup>
Expand All @@ -56,15 +46,4 @@
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

<Target Name="IncludeProjectReferenceInPackage" BeforeTargets="_GetPackageFiles">
<MSBuild Projects="@(ProjectReference)" Targets="Build">
<Output TaskParameter="TargetOutputs" ItemName="ProjectReferenceOutput" />
</MSBuild>

<ItemGroup>
<None Include="@(ProjectReferenceOutput)" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
</ItemGroup>
</Target>

</Project>
1 change: 1 addition & 0 deletions DllImportGenerator/DllImportGenerator/DllImportStub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Microsoft.Interop.SourceGeneration;
using System;
using System.Collections.Generic;
using System.Text;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.CodeAnalysis;
using Microsoft.Interop.SourceGeneration;
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down
10 changes: 0 additions & 10 deletions DllImportGenerator/DllImportGenerator/LanguageSupport.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.Interop.SourceGeneration;
using System;
using System.Collections.Generic;
using System.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/// <summary>
/// Stack-alloc threshold set to 256 bytes to enable small arrays to be passed on the stack.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;

namespace Microsoft.Interop
namespace Microsoft.Interop.SourceGeneration
{
/// <summary>
/// Interface for generation of marshalling code for P/Invoke stubs
/// </summary>
public interface IMarshallingGenerator
internal interface IMarshallingGenerator
{
/// <summary>
/// Get the native type syntax for <paramref name="info"/>
Expand Down Expand Up @@ -71,7 +71,7 @@ public interface IMarshallingGenerator
/// <summary>
/// Exception used to indicate marshalling isn't supported.
/// </summary>
public sealed class MarshallingNotSupportedException : Exception
internal sealed class MarshallingNotSupportedException : Exception
{
/// <summary>
/// Construct a new <see cref="MarshallingNotSupportedException"/> instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/// <summary>
/// Create an <see cref="IMarshallingGenerator"/> instance for marshalling the supplied type in the given position.
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/// <summary>
/// Stack-alloc threshold set to 256 bytes to enable small arrays to be passed on the stack.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)));

Expand Down
Loading

0 comments on commit 7e53797

Please sign in to comment.