Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 340177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:35:30+00:00 2026-05-12T10:35:30+00:00

I have a templating system that looks similar to old-style ASP code. I run

  • 0

I have a templating system that looks similar to old-style ASP code. I run this through a class that rewrites the entire thing into C# source code, compiles, and finally executes it.

What I’m wondering is if there is some kind of #pragma-like directive I can sprinkle the generated C# code with that will make compile errors match the line numbers in my template file?

For instance, let’s say I have this first and only line in my template code:

Object o = datta; // should be data, compiler error

but then in order to compile this I must add a namespace, a class, a method, and some boiler-plate code to it, so this line above, which is line #1 in my template file, actually ends up being line #17 (random number, just for illustrative purposes) in the C# code. The compiler error will naturally flag my error as being on line #17, and not on line #1.

I remember from another programming language I’ve used before (though I can’t remember which one) that it had a directive that I could add, which would make error line numbers line up.

Is there any such thing in C# 3.5?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:35:31+00:00Added an answer on May 12, 2026 at 10:35 am

    You have the #line preprocessor directive.

    #line lets you modify the compiler’s line number and (optionally) the file name output for errors and warnings.

    The #line directive might be used in an automated, intermediate step in the build process. For example, if lines were removed from the original source code file, but you still wanted the compiler to generate output based on the original line numbering in the file, you could remove lines and then simulate the original line numbering with #line.

    The #line hidden directive hides the successive lines from the debugger, such that when the developer steps through the code, any lines between a #line hidden and the next #line directive (assuming that it is not another #line hidden directive) will be stepped over. This option can also be used to allow ASP.NET to differentiate between user-defined and machine-generated code. Although ASP.NET is the primary consumer of this feature, it is likely that more source generators will make use of it.

    A #line hidden directive does not affect file names or line numbers in error reporting. That is, if an error is encountered in a hidden block, the compiler will report the current file name and line number of the error.

    The #line filename directive specifies the file name you want to appear in the compiler output. By default, the actual name of the source code file is used. The file name must be in double quotation marks ("") and must be preceded by a line number.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a quite old templating system written on top of ERB. It relies
I have borrowed code from this link PHP regex templating - find all occurrences
I'm coding a templating system that is supposed to support easily converting any old
I have the following string in the smarty (php templating system) variable $test: <img
Are there any third-party Templating Engines for Asp.net like we have smarty,savant for php
Say I need to have a templating system where a user can edit it
I am currently writing a small templating system in ASP.NET to allow users to
I have a small templating system in javascrip, where the user can put tags
I work on a very high trafficked website that uses a Smarty templating system.
Is there a templating library/system/engine/technique written in javascript that: Doesn't screw up plain-text (non-html)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.