Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declare internal source attributes in consuming projects #218

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion IDisposableAnalyzers/IDisposableAnalyzers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@
</ItemGroup>

<ItemGroup>
<None Update="tools\*" Pack="true" PackagePath="" />
<None Update="tools\*;build\*" Pack="true" PackagePath="" />
<Compile Remove="build\*.cs" />
<None Include="build\*.cs" Pack="true" PackagePath="build" />
jnm2 marked this conversation as resolved.
Show resolved Hide resolved

<None Include="$(OutputPath)\$(AssemblyName).dll;$(OutputPath)\Gu.Roslyn.Extensions.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
</ItemGroup>
</Project>
23 changes: 23 additions & 0 deletions IDisposableAnalyzers/build/IDisposableAnalyzers.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project>

<PropertyGroup>
<OwnershipAttributesPath Condition="'$(OwnershipAttributesPath)' == ''">$(MSBuildThisFileDirectory)OwnershipAttributes$(DefaultLanguageSourceExtension)</OwnershipAttributesPath>

<IncludeOwnershipAttributes Condition="'$(IncludeOwnershipAttributes)' == '' and Exists($(OwnershipAttributesPath))">true</IncludeOwnershipAttributes>
</PropertyGroup>

<ItemGroup Condition="'$(IncludeOwnershipAttributes)' == 'true' and Exists($(OwnershipAttributesPath))">
<Compile Include="$(OwnershipAttributesPath)" Visible="false" />
jnm2 marked this conversation as resolved.
Show resolved Hide resolved

<!-- Workaround for https://github.com/dotnet/wpf/issues/810 -->
<_GeneratedCodeFiles Include="$(OwnershipAttributesPath)" Visible="false" Condition="'$(UseWPF)' == 'true'" />
</ItemGroup>

<Target Name="OwnershipAttributesRequestedForUnsupportedLanguage"
Condition="'$(IncludeOwnershipAttributes)' == 'true' and !Exists($(OwnershipAttributesPath))"
BeforeTargets="Compile">

<Warning Code="IDISP026" Text="The project specifies &lt;IncludeOwnershipAttributes&gt;true&lt;/IncludeOwnershipAttributes&gt;, but including attributes in this language is not yet supported." />
</Target>

</Project>
28 changes: 28 additions & 0 deletions IDisposableAnalyzers/build/OwnershipAttributes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace IDisposableAnalyzers
{
using System;

/// <summary>
/// The return value must be disposed by the caller.
/// </summary>
[AttributeUsage(AttributeTargets.ReturnValue | AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
internal sealed class GivesOwnershipAttribute : Attribute
{
}

/// <summary>
/// The return value must not be disposed by the caller.
/// </summary>
[AttributeUsage(AttributeTargets.ReturnValue | AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
internal sealed class KeepsOwnershipAttribute : Attribute
{
}

/// <summary>
/// The ownership of instance is transferred and the receiver is responsible for disposing.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
internal sealed class TakesOwnershipAttribute : Attribute
{
}
}