C# Sass Compiler - c#

So I have a C# (asp.net) based dashboard for a proprietary content management system. One of the things that the dashboard allows is for the user to go in and add custom css/sass to their site. When they do this, my controller calls a program that compiles the sass using NSass.Core.
Up until now, I have been using Foundation 5 as my responsive framework. Yesterday when attempting to update my controller to allow for Foundation 6 compilation, it started throwing errors. The errors were occurring every time the compiler attempted to parse a sass map (associative array).
I started doing some research into the problem and found out that sass maps are a relatively new mechanic in sass and the last time Nsass was updated was three years ago, so I am assuming this is the problem.
Has anyone had similar experience? If so, what was your solution. If not, does anyone use anything else that would work for me? I have tried installing a couple other packages, but started receiving various other errors such as libsassnet not being able to find the 32 bit dll. Hopefully someone here can give me an answer that saves me some time.
The errors I have received when using Nsass were all along the lines of "error reading values after primary" where primary is the first value in the first map the compiler comes across. When I take that map out, it just moves to the next one and gives the same error.
As far as narrowing my question down... I just want to know what other people are using out there to compile Sass in C#

There is a nuget package: Bundle Transformer: Sass and SCSS is a provider for Bundle Transformer. In turn, this is an extension of System.Web.Optimisation that could allow you to add code to your CMS to compile user generated SCSS into Css files.
An example of this can be found in the Optimus package for the Umbraco CMS. Looking through this code could give you a good basis for creating your own system. If you speak with the Author of the package (a really nice guy) he might be able to help you create your own targeted package that isn't dependent on Umbraco.
Hope that helps.

Related

How to use C# namespaces

I am pretty new to C# but I have worked a little bit for my classes. When I worked in C#for classes, our teacher used to tell us the namespaces that we needed for completing the assignment.
I wanted to know where do I find all the collection of the namespace for C#.
One of my friends directed me to this site
https://learn.microsoft.com/en-us/dotnet/api/index?view=netframework-4.0
but some of the namespaces did not work for example,
enter image description here
I am working on a small project with ASP.NET MVC and wanted to try different namespaces
I think you may be a little confused, or are possibly not asking the question correctly. The link you provided does contain a list of the different libraries (namespaces) available in the C# API.
If you try to use a namespace in your own code, and it does not resolve, you may need to add an assembly reference to bring that namespace into your project. VS usually does a pretty decent job of guessing what assembly, or missing using statement is required if you either press alt+enter, or click the context drop down under the missing library (denoted by the red squiggly).
Either way, you should just start coding your MVC project, and then google the issues you come up with directly. Asking for all the namespaces is very very vague.

Include TFS path in .NET assembly

When troubleshooting our applications, in many situations I cannot be sure what branch the assemblies originally come from, due to an imperfect release cycle and human error.
(We have quite a lot of different bugfix/feature/test/release branches etc. in our TFS).
The PDB-files can help sometimes, in a test environment at least, but sometimes they're missing or outdated / belong to assemblies from another branch.
So, I was trying to think of a way to include the source branch information inside the assembly directly.
Surprisingly, I could not easily find a straight forward way online to accomplish this.
My answer below explains my approach. I would be happy about feedback or alternative solutions.
In short: I created a custom attribute that I put intoAssemblyInfo.cs. Inside the attribute's constructor, the server path for the current assembly is queried from TFS and compiled into it.
It's basically a combination of the following:
Can I add custom version strings to a .net DLL?
How do I get the path of the assembly the code is in?
Get TFS mapped folder of a local sub folder of the solution?
(Note: I cannot post the actual source code due to company restrictions, but I think it's pretty straight forward.)
To get the attribute's value later is unfortunately not as easy as getting the version number from the DLL-file's properties, but at least it is possible now to get the information I need with minimum effort. (I use a small PowerShell script for that.)

Hash of source codes at compile time in C#

Having a server that other devs use, I currently log the version of the dll they use. I do that by having the client that use Reflection to retrieve its version:
Assembly.GetEntryAssembly().GetName().Version.ToString();
It's nice, but since it come from dev that uses TFS and do themself the build, I can not see if they have the latest version of the sources. Is there a trick, like a compilation tag, that would easily allow a hash of the generating source code?
Note: I have try to send the MD5 of the dll (using assembly.Location), but it is useless since the hash value changes between 2 compilations (I suppose there is some compilation timestamp inside the generated dll).
This is most collaboraton issue then a coding.
In the moment that you find out that the version is old one.notify them about it.
If the real version is not old one, that means that developers before making buold did not increment the version ID, which is mistake.
In other words, ordanize it among people, and not relly on these kind of tools (if there is any). You trying to create a complicated tool, that will help you avoid mistakes, but humans will find a way to make them again.
So it's better to create solid relation structure among you, imo.
Create a tool on pre build event to hash/last-write-time your code files.
Write the result to a cs file or a embedded resource file.
The result file must exclude in above action.
For prevent skip build (up-to-date) feature not work,Compare the file before write.
And if youre opening the file in IDE will get a prompt `changed from out side' when build.
Seem there is no easy way to do it.

Flesch-Kincaid Readability in Asp.Net

I'm working on an asp.net content management system and we need to have Flesch-Kincaid grade level stats available to the users. I've done quite a bit of searching and I haven't found any viable ways to implement this. The closest I've come is the MS Word ReadabilityStatistics Property. I can get this to work great in a console app but support for the dll in asp.net isn't supported and I get an access denied error whenever I try to leverage it from my asp.net application. I spent 8 hours the other day trying to get that to work from asp.net with no luck.
Does anyone know of another dll or method to get a FK value? We do tell our content users that the FK value is from MS word, so that'd be best, but really anything which is close would be appreciated at this point. Even an js version would be adequate.
If you're happy translating PHP, the work has been done for you.

Subsonic 3 - Namespace hidden - Probably me

It's Friday so I'm prob doing something stupid here. In fact I'd put money on it.
I'm playing around with Subsonic - got my feet happily into v2.2 but intrigued by v3 alpha
Followed Rob's webcast, did as he did, watched T4 generate the code, went to use the new namespace and oh. No namespace.
I can see the namespace Test.Data in each of the generated .cs files, the tt files are included in the project as is subsonic.dll, there are no errors (I managed to get rid of a warning for the duplicate directives) but I just can't see the namespace.
To test it out I am building a simple vb.net console application so wondering if there is a conflict there. Using v2.2 against the same db works fine.
Ready for you to point and laugh.
Thanks
Yep, as I thought, me being a Friday n00b.
Didn't realise until now that you can't have vb.net and c# code co-existing in anything other than a asp.net project.
Will split into separate assemblies and go from there.
"Nothing to see here, please move along.."
Have a good weekend.
Ed

Categories

Resources