AdaskoTheBeAsT / Typewriter

Automatic TypeScript template generation from C# source files
http://frhagn.github.io/Typewriter
Apache License 2.0
66 stars 13 forks source link

Error when render all templates #29

Open luizfbicalho opened 1 year ago

luizfbicalho commented 1 year ago

I have an error that I get when I render all templates, and I don't get when I run each one

12:14:47.380 ERROR: Cannot find path of project item Object reference not set to an instance of an object.


Microsoft Visual Studio

The path is not of a legal form.

OK

My idea is to put more details in this error.

AdaskoTheBeAsT commented 1 year ago

can you check now? Typewriter is using different way of saving files to workaround 260 characters path limitation

luizfbicalho commented 1 year ago

I still get the error

15:05:21.392 ERROR: Cannot find path of project item Object reference not set to an instance of an object.

and the message The path is not of a legal form.

Is there a way that I can generate more details on the error?

AdaskoTheBeAsT commented 1 year ago

can you please share part of your template?

luizfbicalho commented 1 year ago

I'm not sure I can share all of it, and it only happens when I press "render all templates" If I render each template one by one I don't get this error

Is there a way that I can generate any log and send here?

AdaskoTheBeAsT commented 1 year ago

I have templates which are quite complicated and generate ~200 models - without even sliced template I will not be able to narrow the problem based only on logs

luizfbicalho commented 1 year ago

I think that I explained it wrong this project has about 20 template files (*.tst) if I render one template each at a time, there is no error reported.

image

If I render all templates in one command, then I get the error.

image

The same templates in another project doesn't give the error, even if I render all the templates in one command For me to send something to you, I need to send you all my code.

I want to help you, but I need help to help you, I need some log or some detailed information to see what's goind on I tested the v2.22.0 Version right now, and got the same error

AdaskoTheBeAsT commented 11 months ago

the only thing which can be problematic is when those templates try to operate on same file - did you try to move half of tst files outside of that folder run all templates - if it works then check second part of templates - maybe by using that you will narrow to two or more conflicting templates

luizfbicalho commented 11 months ago

the only thing which can be problematic is when those templates try to operate on same file

They are in different folders, I mean, never the output file name conflicts, but there are cases where I have 2 templates in the same folder, to save one as .ts and other as .html, could be a temporary file with the same name and extension? that in the final could be the same name and different extension

I mean

Suppose that you save a temporary file in the execution folder, if I have two templates in the same folder I could have this conflict

This make any sense?

AdaskoTheBeAsT commented 10 months ago

files are written directly - there are no temp files - please create minumum reproductible - without it I can't analyze stuff

Gambero81 commented 5 months ago

I have the same problem, if i do "Render All Templates" it give me the error "ERROR: Cannot find path of project item Object reference not set to an instance of an object.".

@AdaskoTheBeAsT i checked the source code and the error is written in this method:

File: src\Typewriter\Generation\Controllers\SolutionExtensions.cs

public static string Path(this ProjectItem projectItem)
{
    return ThreadHelper.JoinableTaskFactory.Run(async () =>
    {
        await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
        try
        {
            return projectItem.Properties.Item("FullPath").Value.ToString();
        }
        catch (Exception e)
        {
            Log.Error($"Cannot find path of project item {e.Message}");
        }

        return null;
    });
}

can you add more info in the Log.Error message to track the issue?