Giter Site home page Giter Site logo

damiengkit's Introduction

DamienGKit

This repository consists of various useful classes, templates and helpers from DamienG.com

Contents

  • CSharp Useful classes in the C# language
  • T4 Various templates for the T4 templating system
  • Powershell/SourceTree Scripts to integrate SourceTree with GitHub

Licence

Copyright 2001-2022 Damien Guard.

Licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

damiengkit's People

Contributors

damieng avatar jakehedlund avatar jrob avatar neutmute avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

damiengkit's Issues

Files are generated under the codetemplates folder

I've included the MultipleOutputHelper in ..\CodeTemplates\MvcView so. This is working wonderfull for my modified List.cs.t4, but the extra file created with the manager is created in the ..\CodeTemplates\MvcView folder.
Is this expected or am i doing something wrong?
VS2017 15.5.3

Setting HashValue in Crc32.cs

It seams that that field is protected internal, and therefore cannot be set. Perhaps I am doing something wrong. Using .Net 4.6.

Package the T4 for distribution

At the moment I've cloned the repo as a submodule, but this just doesn't feel right. I certainly don't need the CSharp bits, for instance.

I don't know if NuGet is an appropriate distribution channel for T4-based concerns? Considering also that T4 is a VS extension.

It's a thought.

Thanks!

Manager.Process does not seem to process the previous file

Hello,

It's been awhile since I picked up the ttinclude files. They've been working pretty good for the most part. But I have an issue now.

I have a case where I have two different sections of an Xml document that I am loading and want to output to two different files. Of itself, I have one section working just fine. However, when I add the second section, the first of the two sections does not process. I confirmed I still get the second (last?) section just fine, as per the output time stamp (just now), 2016-04-21T20:43:18.3692075-04:00.

In my generation method, I start with the following:

manager.StartNewFile(GetGeneratedCSharpPath(Host, name));

Following which, after each iteration, I call this:

manager.Process(true);

Where name is the name of the output class, i.e. Instructions in Instructions.Generated.cs.

Perhaps it is a bug in the ttinclude, I do not know. I could be user related, just don't know how to debug it, per se. Only that the first (not the last) output is definitely not being handled properly.

Any ideas?

Exception throw in InitializeTable

The following exception is

Exception IndexOutOfRangeException Source = Crc32Test Message = Index was outside the bounds of the array. TargetSite = UInt32[] InitializeTable(UInt32) Stack =
at this line:
createTable[entry] = entry;
I added this check
System.Diagnostics.Debug.Assert(entry >= 0 && entry < 256); // ANGELO if(entry >= 0 && entry < 256) // ANGELO createTable[entry] = entry;
but probably it would be better to add test and a break in the inner loop, where entry is modified,
Since I didn't know the algorithm and I didn't fully analized the code, I'm not sure about what is correct.

Visual Studio 2015 Update 2 breaks MultipleOutputHelper.ttinclude if you transform at build time.

I have been using your ttinclude to great success.

I have modified the Manager.Create method to support generating templates build time:

public static Manager Create(ITextTemplatingEngineHost host, StringBuilder template) {
    if((host as IServiceProvider) != null)
    {
        var hostServiceProvider = host as IServiceProvider;
        if((EnvDTE.DTE) hostServiceProvider.GetService(typeof(EnvDTE.DTE)) != null)
        {
            return new VSManager(host, template);
        }
    }

    return new Manager(host, template);
}

This way you don't need Visual Studio to build the T4 templates and MSBuild can do it as a build step.

I have added these lines to my csproj to run the textgeneration as a build step:

<PropertyGroup>
  <!-- Get the Visual Studio version โ€“ defaults to 10: -->
  <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
  <!-- Keep the next element all on one line: -->
  <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<PropertyGroup>
  <TransformOnBuild>true</TransformOnBuild>
</PropertyGroup>

<Import Project="$(VSToolsPath)\TextTemplating\Microsoft.TextTemplating.targets" />

This worked fine until updating to Update 2. But now building the project results in this.

Warning: Compiling transformation: Assuming assembly reference 'mscorlib, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' used by 'EnvDTE' matches identity 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' of 'mscorlib', you may need to supply runtime policy. Line=1, Column=1 (0, 0)

I can still ctrl+s the tt file and it generates the output, but I want generation to happen on my build servers using msbuild.

There are somewhat similar reports on the internet, but not sure if this is related: http://stackoverflow.com/questions/35412460/compiling-transformation-the-type-object-is-defined-in-an-assembly-that-is-no

Can you help me figure out why does it want a different version of mscorlib and how can I feed the version it wants to the ttinclude?

CRC32 Performance

Hi, I am using the GitHub's latest CRC32.
During performance test, for 55KB buffer size, it takes 1.36 ms for processing.
Can this be improvised further by parallel processing or any other mechanism.
Please share the latest if performance can be improved.

Attaching the performance captured for CalculateHashmethod.
crc32performance

Output on non existing folders

I found this piece of code on the internet to be called before create the file or in case the folder destination does not exist.

System.IO.FileInfo file = new System.IO.FileInfo(filePath);

I want to modify a little bit the manager and check if the nested folder does exist or create it and then proccess the file.

manager.StartNewFile(@"../../"+Settings.ProjectName+".Services/BaseServices/" + model.Name + "BaseService.cs");

How to do this?

The output file's dependency constraint is vs2015

// Add missing files to the project
foreach (String fileName in keepFileNameSet)
  if (!projectFiles.ContainsKey(fileName))
    templateProjectItem.ProjectItems.AddFromFile(fileName);

When you output a file on a specified path, it cannot be displayed in the project because it is dependent (must be reloaded)

// Add missing files to the project
foreach (String fileName in keepFileNameSet)
  if (!projectFiles.ContainsKey(fileName))
    templateProjectItem.ProjectItems.ContainingProject.ProjectItems.AddFromFile(fileName);
templateProjectItem.ProjectItems.ContainingProject.Save();

fonts`

hi im totally new trying to make a ch8 font /altar one of yours for a game..is there a link how to go about this? thank you..

CRC32 with offset

Hi Damien,

thanks for your code!

I met a problem in the CRC32 code, though. It looks like somebody already reported it on your blog, but as the code still is as it is...

When calling HashAlgorithm.TransformBlock() with say a byte array of size 100, an inputOffset of 10 and an inputCount of 3...

    static UInt32 CalculateHash(UInt32[] table, UInt32 seed, IList<byte> buffer, int start, int size)
    {
        var crc = seed;
        for (var i = start; i < size - start; i++)

...the code tries to loop from 10 upwards to <7 and will not hash any bytes.
It really should be "for (var i = start; i < size + start; i++)" to loop from 10 to <13.

Ciao,
Eike

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.