Using ExcludeFromCodeCoverageAttribute breaks XML Comment - c#

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.

Related

Sergen : syntax erros despite rebuilt

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.

Resharper Intellisense Auto Import

There is a neat little feature in the Resharper Intellisense where it suggests items which are in a namespace you haven't imported yet.
e.g. if you type in StreamReader the Intellisense is showing me the item StreamReader (in System.IO) and if I press enter it is importing the namespace and everything is fine.
But it seems like this feature is just working for System types and not types you have written yourself.
consider the following example:
namespace Test
{
internal class Program
{
internal static void Main()
{
}
}
}
namespace Test.Util
{
internal class Helper
{
}
}
Let's say you want to use your Helper-class in the Main-method. While you are writing Helper you won't get an entry in the intellisense drop down menu like in the StreamReader example. When you exit the intellisense drop down you will get the import message Import 'Test.Util.Helper' and all other references in the file where you can import all missing references.
Is there any way to extend this 'auto import'-feature to show my self-written classes in the intellisense drop down or is this just something I'll have to live with
You can always use import-completion mode when ordinary completion doesn't suggest import items for some reason. It's invoked by Ctrl+Alt+Space.
In your sample, if you write "Hel" and invoke Ctrl+Alt+Space, the item will be auto-imported.
Jetbrains support:
We fixed such issue in ReSharper 9.1 branch and the fix will be
available after ReSharper 9.1 release. Unfortunately, we do not have
exact date of the release.

Do I need two xmlns:local="clr-namespace"?

Here's the setup I'd like to have for my Windows Phone app, using c# in visual studio 2010:
**MainPage.xaml** contains elements that have an attached property, whose values will be modifiable/savable by the user.
**MainPage.xaml.cs**
first Namespace is PhoneApp ,inside it is a nested namespace called MyNamespace that declares the dependency property. it works(Thanks, Daniel)
**SettingsSample.xaml** that will allow users to change the values of the attached property in MainPage.xaml for any element and automatically save the change.
**AppSettings.cs** a class that exactly reproduces the first listing in this tutorial:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff769510%28v=vs.105%29.aspx
That page declares the same NameSpace as the MainPage.xaml.cs (PhoneApp), then a public class called AppSettings that is exactly like in the tutorial.
To join everything together, I did:
**MainPage.xaml**
xmlns:local="clr-namespace:PhoneApp.MyNamespace"
I needed this to use the attached property
<phone:PhoneApplicationPage.Resources>
<local:AppSettings x:Key="appSettings"></local:AppSettings>
</phone:PhoneApplicationPage.Resources>
Confusion begins. On the tutorial, they put this on the settings page, but I guess because their settings page is also the one including the elements with the properties that are bound to the saved settings. Mine are on the mainpage, so I put this here. To recap, My settings page will only use methods to change/save these values(and the methods are in AppSettings.cs). Also in the tutorial they add this:
xmlns:local="clr-namespace:SettingsSample"
to the Setting Page(where "SettingsSample" is the Namespace containing declaration/get-Set methods of savable settings) but, for the same reason, I tried to put it on the mainpage, but only one declaration of xmlns:local can be done. I tried several things to put them one after the other, but it doesn't work. This is the key to the two errors I'll list below.
Some elements of mainpage have this, for exemple:
local:MyClass.Son="{Binding Source={StaticResource appSettings}, Path=son1, Mode=TwoWay}" Style="{StaticResource pad}"
"Son" is the attached property
Ok, so I tried different different things but it never worked. The best I could get was in MainPage.xaml that it couldn't create an instance of AppSettings. Now it's different, I have the two errors.
-the type local:AppSettings was not found
-the tag AppSettings does not exist in xml namespace PhoneApp.MyNamespace.
I think this is because I didn't put the
xmlns:local="clr-namespace:PhoneApp"
But I already have
xmlns:local="clr-namespace:PhoneApp.MyNamespace"
and can't put both.(and to me, one is included in the other...) The reason I listed all the ins and out of the situation is because I kind of expect other troubles after I get through this.
I hope this message is clear enough for someone to help me. I spent so much time on it that I begin to loose my mind, so I hope there's no stupid mistake. Of course, I can add any information needed. Thank you for reading anyway!
These are XML namespace mappings. With the following:
xmlns:local="clr-namespace:PhoneApp"
The local part is the XML namespace, whilst PhoneApp is the namespace from your .NET code. With this definition in place you can then reference classes from this namespace in XML as follows:
<local:MyClassInPhoneAppNamespace/>
Because the local part is simply a name, you can change it to whatever you like:
xmlns:fish="clr-namespace:PhoneApp"
And use as follows:
<fish:MyClassInPhoneAppNamespace/>
This should mean that you no longer have collisions.
"local" in this case is simply a friendly name for the namespace you are referencing. It is completely interchangeable.
I was in need to import two local in same file as below
xmlns:local="clr-namespace:Generique.Views.Assets.Entries"
xmlns:local="clr-namespace:Generique.Views.Assets"
I just change the name and it works fine
xmlns:local="clr-namespace:Generique.Views.Assets.Entries"
xmlns:footer="clr-namespace:Generique.Views.Assets"

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!

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