Skip to content
This repository was archived by the owner on Jun 18, 2026. It is now read-only.
Draft
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
2 changes: 1 addition & 1 deletion doc/Class Lifecycle Generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}
```

1. Compile ([the generation process occurs at compile time](https://github.com/nventive/Uno.SourceGeneration/issues/9)).
1. Compile ([the generation process occurs at compile time](https://github.com/unoplatform/Uno.SourceGeneration/issues/9)).
1. It will generate the following public methods for you:
``` csharp
partial class MyClass : IDisposable
Expand Down
2 changes: 1 addition & 1 deletion doc/Immutable Generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ The generated code will produce the following effect:
```

> For more information on the `Uno.Core` package:
> * On Github: <https://github.com/nventive/Uno.Core>
> * On Github: <https://github.com/unoplatform/Uno.Core>
> * On Nuget: <https://www.nuget.org/packages/Uno.Core/>

# FAQ
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Features:

# Have questions? Feature requests? Issues?

Make sure to visit our [FAQ](doc/faq.md), [StackOverflow](https://stackoverflow.com/questions/tagged/uno-platform), [create an issue](https://github.com/nventive/Uno.CodeGen/issues) or [visit our gitter](https://gitter.im/uno-platform/Lobby).
Make sure to visit our [FAQ](doc/faq.md), [StackOverflow](https://stackoverflow.com/questions/tagged/uno-platform), [create an issue](https://github.com/unoplatform/Uno.CodeGen/issues) or [visit our gitter](https://gitter.im/uno-platform/Lobby).

# Contributing

Expand Down
10 changes: 6 additions & 4 deletions src/Uno.ClassLifecycle/Uno.ClassLifecycle.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ This package is part of the Uno.CodeGen to generate object life cycle methods in
<RootNamespace>Uno</RootNamespace>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
<Copyright>Copyright (C) 2015-2018 nventive inc. - all rights reserved</Copyright>
<PackageProjectUrl>https://github.com/nventive/Uno.CodeGen</PackageProjectUrl>
<RepositoryUrl>https://github.com/nventive/Uno.CodeGen</RepositoryUrl>
<PackageIconUrl>https://nv-assets.azurewebsites.net/logos/uno.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/unoplatform/Uno.CodeGen</PackageProjectUrl>
<RepositoryUrl>https://github.com/unoplatform/Uno.CodeGen</RepositoryUrl>
<PackageIcon>uno.png</PackageIcon>
</PropertyGroup>

<Import Project="..\Uno.Common.props" />

<ItemGroup>
<PackageReference Include="Uno.MonoAnalyzers" Version="1.0.0-dev.4">
<PackageReference Include="Uno.MonoAnalyzers" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>

<None Include="..\uno.png" Pack="true" PackagePath="\" Visible="false" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Uno.CodeGen.ClassLifecycle/ClassLifecycleGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private void Generate(LifecycleMethods methods)
{
writer.WriteLine("// <auto-generated>");
writer.WriteLine("// ***************************************************************************************************************************");
writer.WriteLine("// This file has been generated by Uno.CodeGen (ClassLifecycleGenerator), available at https://github.com/nventive/Uno.CodeGen");
writer.WriteLine("// This file has been generated by Uno.CodeGen (ClassLifecycleGenerator), available at https://github.com/unoplatform/Uno.CodeGen");
writer.WriteLine("// ***************************************************************************************************************************");
writer.WriteLine("// </auto-generated>");
writer.WriteLine("#pragma warning disable");
Expand Down
109 changes: 58 additions & 51 deletions src/Uno.CodeGen.ClassLifecycle/Uno.CodeGen.ClassLifecycle.csproj
Original file line number Diff line number Diff line change
@@ -1,57 +1,64 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<PropertyGroup>
<TargetFrameworks>net461;netstandard1.3;netstandard2.0</TargetFrameworks>
<IsTool>true</IsTool>
<Product>Generator of class lifecycle</Product>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<TreatSpecificWarningsAsErrors />
<DebugType>full</DebugType>
<DebugSymbols>True</DebugSymbols>
<Authors>nventive</Authors>
<Company>nventive</Company>
<IsTool>true</IsTool>
<Product>Generator of class lifecycle</Product>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<TreatSpecificWarningsAsErrors />
<DebugType>full</DebugType>
<DebugSymbols>True</DebugSymbols>
<Authors>nventive</Authors>
<Company>nventive</Company>
<Description>This package provides a generator which generates the class life cycle method using the attributes from Uno.ClassLifecycle.
This package is part of the Uno.CodeGen to generate classes lifecycle methods in your project.</Description>
<RootNamespace>Uno</RootNamespace>
<Copyright>Copyright (C) 2015-2018 nventive inc. - all rights reserved</Copyright>
<PackageProjectUrl>https://github.com/nventive/Uno.CodeGen</PackageProjectUrl>
<RepositoryUrl>https://github.com/nventive/Uno.CodeGen</RepositoryUrl>
<PackageIconUrl>https://nv-assets.azurewebsites.net/logos/uno.png</PackageIconUrl>
</PropertyGroup>

<Import Project="..\Uno.Common.props" />

<ItemGroup Condition="'$(TargetFramework)'=='net461'">
<PackageReference Include="System.ValueTuple" Version="4.4.0" PrivateAssets="all" />
<PackageReference Include="Uno.RoslynHelpers" Version="1.2.0-dev.10" PrivateAssets="all" />
<PackageReference Include="Uno.SourceGeneration" Version="1.30.0-dev.245" PrivateAssets="all" ExcludeAssets="runtime" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Uno.MonoAnalyzers" Version="1.0.0-dev.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Uno.SourceGenerationTasks" Version="1.30.0-dev.245" PrivateAssets="none">
<NoWarn>NU1701</NoWarn>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'!='net461'">
<Compile Remove="**\*.cs" />
<None Include="**\*.cs" Exclude="obj\**\*.cs;bin\**\.cs" />
</ItemGroup>

<ItemGroup>
<Content Include="build/**/*.*">
<Pack>true</Pack>
<PackagePath>build</PackagePath>
</Content>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Uno.ClassLifecycle\Uno.ClassLifecycle.csproj" />
</ItemGroup>

<RootNamespace>Uno</RootNamespace>
<Copyright>Copyright (C) 2015-2018 nventive inc. - all rights reserved</Copyright>
<PackageProjectUrl>https://github.com/unoplatform/Uno.CodeGen</PackageProjectUrl>
<RepositoryUrl>https://github.com/unoplatform/Uno.CodeGen</RepositoryUrl>
<PackageIcon>uno.png</PackageIcon>
</PropertyGroup>

<Import Project="..\Uno.CodeGen.RoslynHelpers\Uno.CodeGen.RoslynHelpers.projitems" Label="Shared" />

<Import Project="..\Uno.Common.props" />

<ItemGroup Condition="'$(TargetFramework)'=='net461'">
<PackageReference Include="System.ValueTuple" Version="4.5.0" PrivateAssets="all" />
<PackageReference Include="Uno.SourceGeneration" Version="3.1.0" PrivateAssets="all" ExcludeAssets="runtime" />

<PackageReference Include="Microsoft.CodeAnalysis" Version="1.3.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="1.3.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="1.3.2" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Uno.MonoAnalyzers" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Uno.SourceGenerationTasks" Version="3.1.0" PrivateAssets="none">
<NoWarn>NU1701</NoWarn>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'!='net461'">
<Compile Remove="**\*.cs" />
<None Include="**\*.cs" Exclude="obj\**\*.cs;bin\**\.cs" />
</ItemGroup>

<ItemGroup>
<Content Include="build/**/*.*">
<Pack>true</Pack>
<PackagePath>build</PackagePath>
</Content>

<None Include="..\uno.png" Pack="true" PackagePath="\" Visible="false" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Uno.ClassLifecycle\Uno.ClassLifecycle.csproj" />
</ItemGroup>

</Project>
42 changes: 42 additions & 0 deletions src/Uno.CodeGen.RoslynHelpers/Extensions/DisposableAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// ******************************************************************
// Copyright � 2015-2018 nventive inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ******************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Uno.RoslynHelpers
{
internal partial class DisposableAction : IDisposable
{
public DisposableAction(Action action)
{
Action = action;
}

public Action Action { get; private set; }

#region IDisposable Members

public void Dispose()
{
Action();
}

#endregion
}
}
74 changes: 74 additions & 0 deletions src/Uno.CodeGen.RoslynHelpers/Extensions/IIndentedStringBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// ******************************************************************
// Copyright � 2015-2018 nventive inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ******************************************************************
using System;

namespace Uno.RoslynHelpers
{
internal partial interface IIndentedStringBuilder
{
/// <summary>
/// Gets the current indentation level
/// </summary>
int CurrentLevel { get; }

/// <summary>
/// Appends text using the current indentation level
/// </summary>
/// <param name="text"></param>
void Append(string text);

/// <summary>
/// Appends formatted text using the current indentation level
/// </summary>
void AppendFormat(IFormatProvider formatProvider, string pattern, params object[] replacements);

/// <summary>
/// Appends a line using the current indentation level
/// </summary>
void AppendLine();

/// <summary>
/// Writes the provided text and adds line using the current indentation level
/// </summary>
void AppendLine(string text);

/// <summary>
/// Creates an indentation block
/// </summary>
/// <param name="count">The indentation level of the new block.</param>
/// <returns>A disposable that will close the block</returns>
IDisposable Block(int count = 1);

/// <summary>
/// Creates an indentation block, e.g. using a C# curly braces.
/// </summary>
/// <returns>A disposable that will close the block</returns>
IDisposable Block(IFormatProvider formatProvider, string pattern, params object[] parameters);

/// <summary>
/// Adds an indentation
/// </summary>
/// <param name="count"></param>
/// <returns></returns>
IDisposable Indent(int count = 1);

/// <summary>
/// Provides a string representing the complete builder.
/// </summary>
string ToString();
}
}
98 changes: 98 additions & 0 deletions src/Uno.CodeGen.RoslynHelpers/Extensions/IndentedStringBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// ******************************************************************
// Copyright � 2015-2018 nventive inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ******************************************************************
using System;
using System.Collections.Generic;
using System.Text;

namespace Uno.RoslynHelpers
{
/// <summary>
/// A C# code indented builder.
/// </summary>
internal partial class IndentedStringBuilder : IIndentedStringBuilder
{
private readonly StringBuilder _stringBuilder;

public int CurrentLevel { get; private set; }

public IndentedStringBuilder()
: this(new StringBuilder())
{
}

public IndentedStringBuilder(StringBuilder stringBuilder)
{
_stringBuilder = stringBuilder;
}

public virtual IDisposable Indent(int count = 1)
{
CurrentLevel += count;
return new DisposableAction(() => CurrentLevel -= count);
}

public virtual IDisposable Block(int count = 1)
{
var current = CurrentLevel;

CurrentLevel += count;
Append("{".Indent(current));
AppendLine();

return new DisposableAction(() =>
{
CurrentLevel -= count;
Append("}".Indent(current));
AppendLine();
});
}

public virtual IDisposable Block(IFormatProvider formatProvider, string pattern, params object[] parameters)
{
AppendFormat(formatProvider, pattern, parameters);
AppendLine();

return Block();
}

public virtual void Append(string text)
{
_stringBuilder.Append(text);
}

public virtual void AppendFormat(IFormatProvider formatProvider, string pattern, params object[] replacements)
{
_stringBuilder.AppendFormat(formatProvider, pattern.Indent(CurrentLevel), replacements);
}

public virtual void AppendLine()
{
_stringBuilder.AppendLine();
}

public virtual void AppendLine(string text)
{
_stringBuilder.Append(text.Indent(CurrentLevel));
}

public override string ToString()
{
return _stringBuilder.ToString();
}
}

}
Loading