Skip to main content

RSCG_TimeBombComment by Andrei Ignat

Nuget / site data

Nuget GitHub last commit GitHub Repo stars

Details

Info

info

Name: RSCG_TimeBombComment

This package make a time bomb from comment.

Author: Andrei Ignat

NuGet: https://www.nuget.org/packages/RSCG_TimeBombComment/

You can find more details at http://msprogrammer.serviciipeweb.ro/category/roslyn/

Source : https://github.com/ignatandrei/RSCG_TimeBombComment

Original Readme

note

RSCG_TimeBombComment aka Time Bomb comment for technical debt

Reference the nuget package

    <PackageReference Include="RSCG_TimeBombComment" Version="2023.5.9.2110"  PrivateAssets="all" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />

Then just add :

//TB: 2021-09-13 this is a comment transformed into an error

and you will see the error!

The general form is

//TB: yyyy-MM-dd whatever here

Examples

//TB: 2020-09-13 this is a comment transformed into an error

will produce an error

Usage for technical debt

When you have a

//TODO

comment in your code, you can transform it into an error time bomb by adding the following line in your project file

//TB: yyyy-MM-dd whatever here and on the date will produce an error when compiling the project

Usage for obsolete methods

Imagine you have a method that is obsolete and you want to remember that you have to remove it. Just put the following line in your project file

[Obsolete("should be deleted on the date on the right", TB_20210915)]
static string Test1()
{
return "asdasd";
}

Then RSCG will create a static const boolean TB_20210915 that will be true if the date is less than 2021-09-15

Also, when you want to test something in your code, but give error if compiled with release

//Just for debug: if(args.length>0) throw new ArgumentException();
//JFD: test

will raise error if compiled with

dotnet build -c release

Other Roslyn Source Code Generators

You can find more Roslyn Source Code Generators at https://github.com/ignatandrei/rscg_examples/

More Roslyn Source Code Generators

You can find more RSCG with examples at Roslyn Source Code Generators

About

note

This will generate an error from the comment after a certain date

How to use

Example ( source csproj, source files )

This is the CSharp Project that references RSCG_TimeBombComment

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="RSCG_TimeBombComment" Version="2023.5.9.2110" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>
</Project>

Generated Files

Those are taken from $(BaseIntermediateOutputPath)\GX


namespace Console_TimeBombComment {
partial class TestClass {
const bool TB_20230508 = true;
}
}


Usefull

Download Example (.NET C# )

Share RSCG_TimeBombComment

https://ignatandrei.github.io/RSCG_Examples/v2/docs/RSCG_TimeBombComment

In the same category (EnhancementProject) - 17 other generators

AutoInvoke.Generator

AutoSpectre

BuildInfo

Com

CommandLine

Credfeto.Version.Information.Generator

LinqGen.Generator

Pekspro.BuildInformationGenerator

PlantUmlClassDiagramGenerator

RSCG_AMS

RSCG_ExportDiagram

RSCG_FunctionsWithDI

RSCG_NameGenerator

RSCG_Wait

ThisAssembly

ThisAssembly.Constants

ThisAssembly.Metadata