Skip to content

Commit

Permalink
namespaces refactoring, small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
tesar-tech committed Nov 30, 2024
1 parent 489cbcb commit 17492fa
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<DocsPageSubtitle>
@using Blazorise.Generator.Features.ApiDocsDtos
<DocsPageSubtitle>
API
</DocsPageSubtitle>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

@using Blazorise.Generator.Features.ApiDocsDtos

@if (filteredApiDocsForComponents.Any())
{
<Heading Margin="Margin.Is2.FromTop.Is3.FromBottom" Size="HeadingSize.Is3">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
namespace Blazorise;
using System;
using System.Collections.Generic;
using System.Linq;
using Blazorise.Generator.Features.ApiDocsDtos;

namespace Blazorise;


public interface IComponentsApiDocsSource
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace Blazorise;
using System;
using System.Linq;

namespace Blazorise.Generator.Features.ApiDocsDtos;

public static class TypeExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using System;

namespace Blazorise.Generator.Features
{
[AttributeUsage( AttributeTargets.Class )]
public class GenerateEqualityAttribute : Attribute
{
namespace Blazorise.Generator.Features;

}
}
[AttributeUsage( AttributeTargets.Class )]
public class GenerateEqualityAttribute : Attribute;
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using System;

namespace Blazorise.Generator.Features
{
[AttributeUsage( AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event )]
public class GenerateIgnoreEqualityAttribute : Attribute
{
namespace Blazorise.Generator.Features;

}
}
[AttributeUsage( AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event )]
public class GenerateIgnoreEqualityAttribute : Attribute;
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
using Blazorise.ApiDocsGenerator.Helpers;
using Microsoft.CodeAnalysis.Text;
using Blazorise.Generator.ApiDocsGenerator.Dtos;
using Blazorise.Generator.ApiDocsGenerator.Extensions;
using Blazorise.Generator.ApiDocsGenerator.Helpers;
using Microsoft.CodeAnalysis;
using System.Collections.Immutable;
using Blazorise.ApiDocsGenerator.Dtos;
using Blazorise.ApiDocsGenerator.Extensions;
using Microsoft.CodeAnalysis.Text;

namespace Blazorise.ApiDocsGenerator;
namespace Blazorise.Generator.ApiDocsGenerator;

[Generator]
public class ComponentsApiDocsGenerator : IIncrementalGenerator

Check warning on line 15 in Source/SourceGenerators/Blazorise.Generator/ApiDocsGenerator/ComponentsApiDocsGenerator.cs

View workflow job for this annotation

GitHub Actions / build

'Blazorise.Generator.ApiDocsGenerator.ComponentsApiDocsGenerator': A project containing analyzers or source generators should specify the property '<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>'

Check warning on line 15 in Source/SourceGenerators/Blazorise.Generator/ApiDocsGenerator/ComponentsApiDocsGenerator.cs

View workflow job for this annotation

GitHub Actions / build

'Blazorise.Generator.ApiDocsGenerator.ComponentsApiDocsGenerator': A project containing analyzers or source generators should specify the property '<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>'
Expand All @@ -25,11 +25,13 @@ public void Initialize( IncrementalGeneratorInitializationContext context )
var (compilation, components) = source;
INamespaceSymbol namespaceToSearch = GetNamespaceToSearch( compilation );
var sourceText = GenerateComponentsApiSource( compilation, components, namespaceToSearch );
ctx.AddSource( "ComponentsApiSource.g.cs", SourceText.From( sourceText, Encoding.UTF8 ) );
ctx.AddSource( "ApiDocsSourceGenerated/ComponentsApiSource.g.cs", SourceText.From( sourceText, Encoding.UTF8 ) );
// ctx.AddSource( "Log.txt", SourceText.From( Logger.LogMessages, Encoding.UTF8 ) );
} );
}

private const string ApiDocsSourceNamespace = "ApiDocsSourceGenerated";

private INamespaceSymbol GetNamespaceToSearch( Compilation compilation )
{
Logger.LogAlways( DateTime.Now.ToLongTimeString() );
Expand Down Expand Up @@ -137,8 +139,10 @@ private static string GenerateComponentsApiSource( Compilation compilation, Immu
$$"""
using System;
using System.Collections.Generic;
using Blazorise.Generator.Features.ApiDocsDtos;
namespace Blazorise.Docs;
namespace Blazorise.{{ApiDocsSourceNamespace}};//CHANGING this requires also changes to Blazorise.Weavers.Fody, where the removal is done.
public class ComponentApiSource_ForNamespace_{{namespaceToSearch.Name}}:IComponentsApiDocsSource
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using Microsoft.CodeAnalysis;

namespace Blazorise.ApiDocsGenerator.Dtos;
namespace Blazorise.Generator.ApiDocsGenerator.Dtos;

public record ComponentInfo( INamedTypeSymbol Type, IEnumerable<IPropertySymbol> Properties, IEnumerable<IMethodSymbol> PublicMethods, IEnumerable<INamedTypeSymbol> InheritsFromChain )
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using Blazorise.ApiDocsGenerator.Helpers;
using Blazorise.Generator.ApiDocsGenerator.Helpers;
using Microsoft.CodeAnalysis;

namespace Blazorise.ApiDocsGenerator.Extensions;
namespace Blazorise.Generator.ApiDocsGenerator.Extensions;

public static class EnumerableExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;

namespace Blazorise.ApiDocsGenerator.Helpers;
namespace Blazorise.Generator.ApiDocsGenerator.Helpers;

public static class DefaultValueHelper
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace Blazorise.ApiDocsGenerator.Helpers;
namespace Blazorise.Generator.ApiDocsGenerator.Helpers;

public enum ExtractorParts
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;

namespace Blazorise.ApiDocsGenerator.Helpers;
namespace Blazorise.Generator.ApiDocsGenerator.Helpers;


/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System.Collections.Generic;
using Blazorise.ApiDocsGenerator.Dtos;
using System.Linq;
using Blazorise.Generator.ApiDocsGenerator.Dtos;
using Blazorise.Generator.ApiDocsGenerator.Extensions;
using Microsoft.CodeAnalysis;
using System.Linq;
using Blazorise.ApiDocsGenerator.Extensions;


namespace Blazorise.ApiDocsGenerator.Helpers;
namespace Blazorise.Generator.ApiDocsGenerator.Helpers;

public class InfoExtractor
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace Blazorise.ApiDocsGenerator.Helpers;

using System.Text;
using System.Text;

namespace Blazorise.Generator.ApiDocsGenerator.Helpers;

/// <summary>
/// This looks silly, but works surprisingly well.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
using Blazorise.ApiDocsGenerator.Dtos;
using Blazorise.ApiDocsGenerator.Extensions;
using Microsoft.CodeAnalysis;

namespace Blazorise.ApiDocsGenerator.Helpers;
namespace Blazorise.Generator.ApiDocsGenerator.Helpers;

/// <summary>
/// Methods that are too small to have their own file
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using System.Linq;
using System.Text.RegularExpressions;

namespace Blazorise.ApiDocsGenerator.Helpers;

using System.Text;
using System.Text.RegularExpressions;
using System.Xml.Linq;

namespace Blazorise.Generator.ApiDocsGenerator.Helpers;

public class XmlCommentToHtmlConverter
{
public string Convert( string xmlComment )
Expand Down

0 comments on commit 17492fa

Please sign in to comment.