T4 for Sharp Architecture/Northwind Problem - t4

I have just downloaded sharparchitecture/Northwind and i'm trying to
get crud scaffolding to work. I have changed nothing except adding
missing reference to this class library. I try to run
ScaffoldingGeneratorCommand.tt and I hit following 3 errors.
Error 1 Compiling transformation: Invalid token 'this' in
class,
struct, or interface member declaration file:BaseTemplate.tt
Error 2 Compiling transformation: Class, struct, or interface
method
must have a return type file:BaseTemplate.tt
Error 3 Compiling transformation: Type expected file:BaseTemplate.tt
Compiler says they occur in the first line of BaseTemplate.tt but i
don't
think that is the true reason.
Has anybody had this problem?
Do you have any idea what can i do to fix it?
Thanks a lot for your time,
PK

I have received this using other T4 templates. The problem ends up being spaces at the end of the file (following the very last '#>' ).
Open your .tt file in VS, CTRL+END, make sure all spaces are removed following the last #>
string someMethod()
{
//some code
return "someValue";
}
#>
Props go to a post by Cheverton:
http://social.msdn.microsoft.com/Forums/en-SG/vsx/thread/cd1217c1-39b0-4799-86a2-2449e21a8544

I realize this is an old question, but I had the same problem just now, and in my case it turns out it was the line endings. They were LF, but needed to be CRLF.
After I made some edits to the .tt file, closed the editor, and opened it again, I had both LF and CRLF line endings in the same file, at which point Visual Studio offered to fix this for me. Once I had consistent CRLF line endings in the .tt file, it worked.

Related

VB6.0 extension/reference bug, getting error "Method or data member not found"

Note: I'm not an experienced programmer
I've been handed some old VB6.0 programs for my work, which were compiling and running successfully in the past, but now when I try to compile, the error "Method or data member not found" is coming up on some ".Text" property calls.
I'm very confident that it's most likely not the code because it was working before it was assigned to me, so possibly the issue is extensions/references that are no longer accessible by the program. However, I'm sure some people will want to see the code so I've provided a few .Text calls, all of which are following a text field. For legal reasons, I can't copy the program but here are a few calls:
'Ex1: Line 312 frmMain
Print #gintAteDataFile, Tab; gstrDate; Tab; gstrtime; Tab; Tab; “Technician: “; frmTechId.mebTechId.Text
'Ex2: Line 4 frmSerialNumber
gstrSerialNumber = MaskEdBox1.Text
'Ex3: Line 34 frmComSetup
If IPControl1.IsBlank Or mebPortNumber.Text = vbNullString Then
I have been unable to locate an answer on Google. Does anyone know what references or extensions are necessary for VB6.0 for a property such as ".Text" to not be called correctly? Thank you

Reading an array from a text file

I have a problem. When the program reads a text file, it always get out of the line and crashed.
var f:text;
i,j,cs:byte;
a:array[0..10,0..10] of int64
begin
assign(f,'anything.txt');
reset(f);
cs:=0;
while eoln(f)=false do
begin
read(f,a[0,cs]);
inc(cs);
end;
close(f);
end.
Here is the content of anything.txt:
2 4 8 16
exitcode=201
You have not told us which compiler you are using.
In Delphi and Turbo Pascal which preceded it, run-time error 201 means "range check error". I don not still have Turbo Pascal installed but your program compiles and runs as a "console application" correctly in Delphi with only one minor change, namely to insert a semi-colon (';') after int64. It runs correctly whether the compiler has range-checking turned on or not.
It also runs correctly in FreePascal + Lazarus.
So, unless you are using a different compiler which also happens to have a run-time error code 201, your problem seems to be caused by something you have not included in your question. In any case you should learn to debug this kind of problem yourself. So:
Look up how to use use the debugger in your Pascal compiler. Place a breakpoint on the line inc(cs) e.g. by pressing F5and run the program. When it stops at the BP, place debug watches (using Ctrl-F5 in Delphi/TP) on the values of cs and a and observe the values carefully. Press F8 repeatedly to single step the program, and see if you can see where and why it goes wrong.
One possibility for what is causing your problem is that you are not reading the copy on anything.txt you think you are: because you don't include a path to the file in assign(f Windows will use the copy of anything.txt, if any, in whatever it thinks the current directory is. To avoid this, include the path to where the file is, as in
assign(f, 'C:\PascalData\Anything.Txt');
Also btw, you don't need to compare a boolean function (or expression) againt true or false as in
while eoln(f)=false do
Instead you can simply do
while not eoln(f) do

Changing generic value in Quartus doesnt affect the result of compilation

I've got an issue with generics in Quartus.
They do work, but if I declare let's say n = 10, and later change it to n = 100, the compilation and simulation results do NOT change. It's as if the generic value was still n = 10.
I've tried recompiling the design, but it didn't work. I've tried deleting temporary files, by removing all directories in my project folder, but still nothing. I've tried archiving the project and restoring it - nope.
Only copying the content of VHDL file, inserting it into a new file with a different name, and recompiling seems to work.
Is there a way to force Quartus into acknowledging the generic value has changed? I suppose I could give those values a thought before inserting them, but for obvious reasons creating a new file, creating a new symbol, and changing the main design file is a BIT of annoyance. Any idea what can I do about that? Is there anything?
Looks like top level schematic .bdf file is here at fault. Ive tried updating symbol after recompiling, it doesnt help. Deleting and re-adding component does help. After ditching main graphic file, and setting my VHDL design as top-level entity (with generic inside) simple re-compilation solves the problem.
Good job, Quartus. Good job.
The problem is in top.vhd. To use generics with schematic view you need to do this:
take in focus <your_top_bdf_with_generics>
go to "File"
click "Create\Update"
click "Create HDL Design File for Current File"
After this your generics will be used.
GL

TypeScript cast (assertion) results in Syntax Error compiler warning?

I've got a TypeScript script that has to interact with a third-party vendor that uses global functions as callbacks (you can't pass in a callback). For instance, to "listen" for a result from their "API", you define the function SetElqContent. E.g.,
window.SetElqContent = function(){/* handle result */};
When the TypeScript compiler sees this line, it complains that The property 'SetElqContent' does not exist on value of type 'Window'.
I thought I could get around this by simply casting to type "any". Actually, this isn't type casting but type assertion, but I think of it as casting, although I understand it's not quite the same. So, I tried:
(<any>window).SetElqContent = function(){/* handle result */};;
To m y surprise, this results in Syntax error, and the line number and column points to the < character in the <any> cast. I tried a few other variants, and I get Syntax error on the initial < of the cast no matter what kind of cast I was doing:
var windowAny = <any>window;
var docElement = <HTMLElement>window.document;
What is it about my type assertions that is invalid syntax?
I'm using Visual Studio 2013 with Update 2, which has a "compile on save" feature for TypeScript files. That's how I'm compiling my .ts files, and it's from in Visual Studio where the Syntax error message is emitted.
UPDATE: Apparently this is related to Visual Studio. When I use the standalone tsc compiler to compile the same file, it emits no errors or warnings.
Apparently my syntax is correct but there is a bug in the Visual Studio tooling. I can't provide exact reproduce steps, and in fact, deleting everything in the .ts file, saving, then restoring the code (via ctrl-z) and resaving caused the "syntax error" warning to disappear.
If I can determine any more specifics about what causes this issue to manifest, I'll report back.
Best way is to create a type definitions file for it
If the library name is eloqua.js, you create a eloqua.d.ts file and refer to it in your .js file like
/// < reference path="../typings/eloqua.d.ts" />
There are many type definition files online available at definitelyTyped website.
https://github.com/borisyankov/DefinitelyTyped
You can contribute yours to there as well.
If you extend the Window interface definition, you'll remove the error:
interface Window {
SetElqContent: Function;
}
window.SetElqContent = function(){/* handle result */};
Here is how you can do the assertion properly:
function SetElqContent(){/* handle result */};
// FINE
(<any>window).SetElqContent = SetElqContent;
or
// FINE
(<any>window).SetElqContent = function SetElqContent(){/* handle result */};
However you should avoid asserting and just do what Steve Fenton recommends as it is more discoverable
Update
Demo in VS:

VS 2010 Intellisense mess while trying to type lambda expression in EF 4.0 query

Short time ago I came into a strange situation .
Here the code I want to write first:
context.Customers.Where(c => c.Name == customerName);
In VS2010 I can't finish this line, at the moment of typing the lambda expression.
context.Customers.Where(c
changes to IDE suggestion
context.Customers.Where(customer
Finally I wrote it after deleting it manually and code within brackets are underlined red.
"C#: Unknown Method 'Where(?)' of 'System.Data.Objects.ObjectSet
First time I see this. Is this an IDE bug? How can I fix it? Thanks.

Resources