Skip to content

Generator stops generating code with multi-project solution #76

@persn

Description

@persn

This problem is a little complicated to setup but I think I was able to find a minimal reproduction, although I can't even begin to guess what could be wrong here. It specifically happens when using 3+ projects with InternalsVisibleTo and SYNC_METHOD_GENERATOR_DISABLE_ATTRIBUTE_GENERATION. The code generator doesn't generate any code in Project 3, there's no Foo3(). It happens completely silently and I have to try and reference the method or add it as a interface contract to force a build error.

Project 1

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Zomp.SyncMethodGenerator" Version="1.3.44">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

</Project>

Project 2

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Zomp.SyncMethodGenerator" Version="1.3.44">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\TestInternals1\TestInternals1.csproj" />
  </ItemGroup>

</Project>
using System;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("TestInternals3")]

Project 3

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <DefineConstants>$(DefineConstants);SYNC_METHOD_GENERATOR_DISABLE_ATTRIBUTE_GENERATION</DefineConstants>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Zomp.SyncMethodGenerator" Version="1.3.44">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\TestInternals2\TestInternals2.csproj" />
  </ItemGroup>

</Project>
using System;
using System.Threading.Tasks;

namespace TestInternals3
{
    public interface IFoo // The build finishes without any complaints so this interface will force a compiler error if it fails to generate the sync version of the method
    {
        void Foo();
        Task FooAsync();
    }

    public partial class Class1 : IFoo
    {
        [Zomp.SyncMethodGenerator.CreateSyncVersion(OmitNullableDirective = true)]
        public Task FooAsync() => Task.CompletedTask;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions