Skip to content

Commit

Permalink
MixIn attribute not compiling when ImplicitUsings is disabled: Fixes #36
Browse files Browse the repository at this point in the history
 (#37)
  • Loading branch information
mrpmorris committed Sep 22, 2023
1 parent 56c4fe6 commit bf58a46
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 25 deletions.
3 changes: 3 additions & 0 deletions Docs/releases.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Releases

## New in 1.8
* Fix: When `ImplicitUsings` is disabled for a project, the attribute for a MixIn won't compile [Fixes #36](https://github.com/mrpmorris/Morris.Moxy/issues/36).

## New in 1.7
* Fix: Moxy stops generating code when @moxy header is malformed [Fixes #33](https://github.com/mrpmorris/Morris.Moxy/issues/33)

Expand Down
6 changes: 3 additions & 3 deletions Publish.bat
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
cls
@echo **** 1.6.0 : UPDATED THE VERSION NUMBER IN THE PROJECT *AND* BATCH FILE? ****
@echo **** 1.8.0 : UPDATED THE VERSION NUMBER IN THE PROJECT *AND* BATCH FILE? ****
pause

cls
@call BuildAndTest.bat

@echo ======================

set /p ShouldPublish=Publish 1.6.0 [yes]?
set /p ShouldPublish=Publish 1.8.0 [yes]?
@if "%ShouldPublish%" == "yes" (
@echo PUBLISHING
dotnet nuget push .\Source\Lib\Morris.Moxy\bin\Release\Morris.Moxy.1.6.0.nupkg -k %MORRIS.NUGET.KEY% -s https://api.nuget.org/v3/index.json
dotnet nuget push .\Source\Lib\Morris.Moxy\bin\Release\Morris.Moxy.1.8.0.nupkg -k %MORRIS.NUGET.KEY% -s https://api.nuget.org/v3/index.json
)

Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ private static void GenerateClassSource(ParsedTemplate parsedTemplate, IndentedT
writer.WriteLine($"using {attributeUsingClause};");
writer.WriteLine();

writer.WriteLine("[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true)]");
writer.WriteLine($"internal class {parsedTemplate.Name}Attribute : Attribute");
writer.WriteLine("[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Struct, AllowMultiple = true)]");
writer.WriteLine($"internal class {parsedTemplate.Name}Attribute : System.Attribute");
using (writer.CodeBlock())
{
GenerateClassProperties(parsedTemplate, writer);
Expand Down
35 changes: 17 additions & 18 deletions Source/Tutorials/01-MixInAMethod/MixInAMethod/MixInAMethod.csproj
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<RootNamespace>$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<RootNamespace>$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
</PropertyGroup>

<ItemGroup>
<None Remove="Mixins\SayHello.mixin" />
</ItemGroup>
<ItemGroup>
<None Remove="Mixins\SayHello.mixin" />
</ItemGroup>

<ItemGroup>
<AdditionalFiles Include="Mixins\SayHello.mixin" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Lib\Morris.Moxy\Morris.Moxy.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="Mixins\SayHello.mixin" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Lib\Morris.Moxy\Morris.Moxy.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
public void SayHello()
{
Console.WriteLine("Hello");
System.Console.WriteLine("Hello");
}
}
}
2 changes: 1 addition & 1 deletion Source/Tutorials/01-MixInAMethod/MixInAMethod/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

using MixInAMethod;

Console.WriteLine("Hello, World!");
System.Console.WriteLine("Hello, World!");

var person = new Person();
person.SayHello();

0 comments on commit bf58a46

Please sign in to comment.