Sergen : syntax erros despite rebuilt - c#

For one of my internship mission, I need to use a C# app-builder, serenity.is with Visual Studio 2015. I'm following this official tutorial.
More precisely, I followed the begin of the tutorial p 43. (I'm just adapting it to what I do, I join the code at the end of the post).
Nothing is going wrong till p 49. The code generator of the app-builder, sergen.exe, is creating some code (I don't have the detail of what he creates but it doesn't seem to be important).
They ask me to "rebuild all", what I did, and everything should work smoothly.
As project is modified, Visual Studio will ask if you want to reload changes, click Reload All.
REBUILD the Solution and then press F5 to launch application.(tutoriel)
Nevertheless, when i compile and execute my code, I've got a bunch of syntax error which shouldn't happen.
You can find the code of my migration file below, but I don't think it is the problem.
using FluentMigrator;
using System;
using FluentMigrator.Infrastructure;
namespace Serene3.Migrations.DefaultDB
{
[Migration(20170802070000)]
public class DefaultDB_20170802_070000_TcpDump : Migration
{
public override void Up()
{
Create.Schema("tcpdump");
Create.Table("TCPDump").InSchema("tcpdump")
.WithColumn("TimeStp").AsString(16).Nullable()
.WithColumn("IdTransmission").AsInt32().Identity().PrimaryKey().NotNullable()
.WithColumn("IdSource").AsString(32).Nullable()
.WithColumn("IdDestination").AsString(32).Nullable()
.WithColumn("PortSource").AsString(16).Nullable()
.WithColumn("PortDestination").AsString(16).Nullable()
.WithColumn("-->").AsInt32().NotNullable()
.WithColumn("<--").AsInt32().NotNullable();
}
public override void Down()
{
}
}
}
I tried to stay as close as the tutorial as possible. I probably forgot to do something, but I can't find what.
Is there any Serenity user which could help?
Feel free to ask any other details

Make sure that all column names are supported by the tool. Column names like "-->" and "<--" would need special syntax in SQL and can't be used as property names in generated code files.
Use property-ready names without special characters or spaces. If you need special names, consult the tools documentation and make sure to use supported techniques.

Related

C# rule for public fields

I have problem with public fields, which I use from time to time in my code. I keep forgeting to change them to private and create properties for them- especialy when Im testing some new part of code (and Im used to create public field for testing at first).
I was thinking that it would be fine to see some sort of "warning" if I use public field in my code.
I have found out, that I can create a ruleset (Im using Visual Studio Community 2013) and choose any of the rule I need. I searched for the rules relative to public fields and found these 2: CA2211: Non-constant fields should not be visible and CA1051: Do not declare visible instance fields. I checked these in the ruleset, tried to Run code analysis on whole solution but I cant see any warnings in the outcome.
I even tried to add something like public int i; in one of my classes but still nothing.
Do you know if I have the right rules or whether there is something else I should do to get the warning? Thank you.

Most efficient way to move an inline class, interface, or enum to it's own file in Visual Studio

Sometimes when I'm developing I may prefer to quickly inline classes, interfaces and/or enums when I'm building a fresh design or from within a test fixture. However, I find it inconvenient to interrupt my thought process to create new code files, copy and paste the class/interface/enum written inline to the new file, and all the time it takes to navigate between them.
I'm looking for an extension, macro, or hidden shortcut combo that will automatically create a file for the highlighted or selected inline class/interface/enum, and, if possible, copy the using list so that it can be built (but remove & sort will clean it up later).
I'm open to extensions, macros, or hidden shortcut keys. Suggestions?
Edit #1: ReSharper looks awesome, yes, and it appears to have exactly what I need, but I would like to find a free solution, if it exists, that didn't push me back $200.
Edit #2: After your helpful input, I'm pushing for my dev team to all run the ReSharper trial, and re-evaluate in a few weeks if the value-add is worth it. We want keep our extension use consistent, so I'm hoping we all find it equally worthwhile.
Example: I want to turn this (IExample.cs):
using System.Linq;
public interface IExample
{
}
public class Example : IExample
{
}
public enum ExampleType
{
}
...into these:
IExample.cs:
using System.Linq;
public interface IExample
{
}
Example.cs
using System.Linq;
public class Example : IExample
{
}
ExampleType.cs
using System.Linq;
public enum ExampleType
{
}
The built in refactoring tools do not have a simple way to extract a class to its own file, so the simplest thing to do if you do not have a refactoring tool like Resharper or Refactor! Pro that do have it is to:
Copy the class to memory.
Add a new file with the class name.
Paste the class to the new file.
ReSharper offers the feature Move to another file to match type name, the ALT+Enter shortcut makes your work faster.
Devexpress Refactor!pro can be your solution....in example you posted, refactor! Pro shows a quick action menu at the bottom of the class name that you want to move.
In this Actionmenu there s the "Move to file" option that' s all you need....
EDIT:
Apparently, this method does move the type to its own file but still keeps the relationship with the previous class, so it won't actually change anything other than generate a seperate file. The type will still be nested in the same way.
This is a pretty old question and I just encountered the same issue.
In Visual Studio 2019 (and probably in 2017 as well, though I did not check),
you can select the entire class -> right click -> Quick Actions and Refactoring -> Move Type to its own file.
It correct all references to said type, too.
Very handy!

Using ExcludeFromCodeCoverageAttribute breaks XML Comment

Im using Visual Studio 2010 with c#.
I'm using XML documentation in my project and successfully added comments.
Successfully means there are noch compilerwarnings about missing XML comments.
Then I checked the codevoverage for my project and started to exclude some files from codecoverage calculation with System.Diagnostics.CodeAnalysis.[ExcludeFromCodeCoverageAttribute]
I did it in the following way:
...
using System.Diagnostics.CodeAnalysis;
namespace MyAppp
{
[ExcludeFromCodeCoverageAttribute]
/// <summary>My comment</summary>
public partial class FDB_PolicyGruppen : Form
{ ...
}
}
The problem is, as soon as I put [ExcludeFromCodeCoverageAttribute] before a comment, I receive the warnings
CS1591: Missing XML comment for publicly visible type or member
or
CS1587 XML comment is not placed on a valid language element.
Hmm that sounds like a bug in whatever you are using to measure code coverage or you have made a copy and paste error hwne juggling things about, i can see how positioning of the comments might affect something that is looking for comments but something measuring code coverage shouldn't even notice comments wherever they happen to be.

Shortcut for autocompleting properties in visual studio?

I was watching a video about C# and the guy used a shortcut to implement a property.
public decimal Price { get; set; }
He wouldn't write the whole line, but instead let the visual studio editor fill in the get and set. Does anyone know the shortcut for completing the last part of the line above? Or even better, like a pdf quick-reference overview?
In Visual Studio 2010 you can type 'prop' then press tab twice. It's probably the same in earlier versions.
Edit: You'll then have to change the type (defaults to int) and the name (defaults to MyProperty).
Edit2: I've just found this great tool that allows you to edit these code snippets to override their default behaviour, or create new ones: http://snippeteditor.codeplex.com/

Has anyone seen a dataset break after adding a new tableadapter?

I have a dataset in a project which I'm using to provide databinding for winforms controls. Everything has been working fine (tableadapters with select, insert, update, delete methods provided by stored procedures) until I added another tableadapter this morning.
Since adding it, every tableadapter in the dataset broke. My project now has 63 errors reporting errors along the lines of :
Error 60 The type name 'SelectCompanyStatusesDataTable' does not exist in the type '..Search.Presentation.dsSearchTableAdapters.dsSearch' C:\Data\Visual Studio Projects\.\..Search.Presentation\dsSearch.Designer.cs 32210 33 ..Search.Presentation
(Using and to censor sensitive names)
I'm at a complete loss with regards to what has gone wrong, let alone how to fix it.
I'm wondering, has anyone seen anything like this happen before and maybe provide a few pointers for what direction I shoulod be looking in?
I know this is an old question but this just happened to me and I managed to fix all the compile errors by clearing out the MyDataSet.cs file (not the MyDataSet.Designer.cs file).
The MyDataSet.Designer.cs file has the following:
namespace MyNamespace {
[.....]
public partial class MyDataSet : global::System.Data.DataSet {
.
.
.
and the MyDataSet.cs file is usually empty (from looking at an old version). But for some reason (I think maybe double-clicking in the dataset designer while adding a new tableadapter), the MyDataSet.cs file had the following contents:
namespace MyNamespace.MyDataSetTableAdapters {
public partial class MyDataSet {
}
}
which, as you can see, doesn't match up with the definition in MyDataSet.Designers.cs.
Clearing MyDataSet.cs removed all the 'The type name 'MyDataTable' does not exist in the type MyNamespace.MyDataSetTableAdapters.MyDataSet' errors.
I know this is old but I found this by googling so hopefully it'll help someone else out!
I have only encountered this after an unsuccessful attempt to rename a dataset's namespace -- the namespace and classnames in the auto-generated and manually generated partial classes didn't match.
In the end I went for a scorched-earth policy and created a new dataset with a slightly different name, and used cut and paste to get the items of the designer in the original into the new dataset. I then deleted the original and updated all references to use the new one.
Thanks...this just happened to me as well.
I used the rightclick "rename" on the dataset.xsd to rename a datatable and adapter.
Blew everything away.
bummer....last couple hours gone.
Joe
It can happen if the connection string in the project settings changes, before a schema modification too. I know because it happened many times where I worked. I am an expert at fixing data-sets and also know some run-time work-rounds.

Categories

Resources