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 458ccab
Show file tree
Hide file tree
Showing 41 changed files with 125 additions and 129 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
4 changes: 2 additions & 2 deletions DllImportGenerator/DllImportGenerator/GeneratorDiagnostics.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using Microsoft.CodeAnalysis;
using Microsoft.Interop.SourceGeneration;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;

namespace Microsoft.Interop
{

/// <summary>
/// Class for reporting diagnostics in the DLL import generator
/// </summary>
public class GeneratorDiagnostics : IGeneratorDiagnostics
internal class GeneratorDiagnostics : IGeneratorDiagnostics
{
public class Ids
{
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 Expand Up @@ -42,7 +42,7 @@ public static Diagnostic CreateDiagnostic(
}
}

public interface IGeneratorDiagnostics
internal interface IGeneratorDiagnostics
{
/// <summary>
/// Report diagnostic for marshalling of a parameter/return that is not supported
Expand All @@ -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);
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 Expand Up @@ -114,7 +114,7 @@ public IEnumerable<StatementSyntax> Generate(TypePositionInfo info, StubCodeCont
/// and <see href="https://en.cppreference.com/w/cpp/language/types">C++</see>, but those is implementation defined.
/// Consult your compiler specification.
/// </remarks>
public sealed class ByteBoolMarshaller : BoolMarshallerBase
internal sealed class ByteBoolMarshaller : BoolMarshallerBase
{
public ByteBoolMarshaller()
: base(PredefinedType(Token(SyntaxKind.ByteKeyword)), trueValue: 1, falseValue: 0, compareToTrue: false)
Expand All @@ -128,7 +128,7 @@ public ByteBoolMarshaller()
/// <remarks>
/// Corresponds to the definition of <see href="https://docs.microsoft.com/windows/win32/winprog/windows-data-types">BOOL</see>.
/// </remarks>
public sealed class WinBoolMarshaller : BoolMarshallerBase
internal sealed class WinBoolMarshaller : BoolMarshallerBase
{
public WinBoolMarshaller()
: base(PredefinedType(Token(SyntaxKind.IntKeyword)), trueValue: 1, falseValue: 0, compareToTrue: false)
Expand All @@ -139,7 +139,7 @@ public WinBoolMarshaller()
/// <summary>
/// Marshal a boolean value as a VARIANT_BOOL (Windows OLE/Automation type).
/// </summary>
public sealed class VariantBoolMarshaller : BoolMarshallerBase
internal sealed class VariantBoolMarshaller : BoolMarshallerBase
{
private const short VARIANT_TRUE = -1;
private const short VARIANT_FALSE = 0;
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
Loading

0 comments on commit 458ccab

Please sign in to comment.