Git Product home page Git Product logo

Comments (4)

hansWurst-creator avatar hansWurst-creator commented on August 20, 2024

I am having the same issue. With some packages where there are name conflicts its too easy to get the wrong using added silently and only noticing when the options of the method are not as expected.

from vscode-csharp.

genlu avatar genlu commented on August 20, 2024

I think this would help the problem you described dotnet/roslyn#66898
@dibarbet do we have the infrastructure to implement the proposal above in vscode?

from vscode-csharp.

logiclrd avatar logiclrd commented on August 20, 2024

Hmm, in a round-about way that could work, but is it guaranteed to return the file to the state it was in before the directive was added?

For instance, I like to space out my usings into groups:

using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

using DeltaQ.RTB.ActivityMonitor;
using DeltaQ.RTB.Diagnostics;
using DeltaQ.RTB.FileSystem;
using DeltaQ.RTB.Interop;
using DeltaQ.RTB.StateCache;
using DeltaQ.RTB.Storage;
using DeltaQ.RTB.SurfaceArea;
using DeltaQ.RTB.Utility;

If, in mistyping something, I accidentally refer to, say, ProvidedInstanceActivator from Autofac.Core.Activators.ProvidedInstance, then this will add a new using directive in the gap between the two:

using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Autofac.Core.Activators.ProvidedInstance;
using DeltaQ.RTB.ActivityMonitor;
using DeltaQ.RTB.Diagnostics;
using DeltaQ.RTB.FileSystem;
using DeltaQ.RTB.Interop;
using DeltaQ.RTB.StateCache;
using DeltaQ.RTB.Storage;
using DeltaQ.RTB.SurfaceArea;
using DeltaQ.RTB.Utility;

I correct my error and go on my merry way, and then when I save the document, the unused using directive gets removed -- it's going to leave the code like this, right?

using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using DeltaQ.RTB.ActivityMonitor;
using DeltaQ.RTB.Diagnostics;
using DeltaQ.RTB.FileSystem;
using DeltaQ.RTB.Interop;
using DeltaQ.RTB.StateCache;
using DeltaQ.RTB.Storage;
using DeltaQ.RTB.SurfaceArea;
using DeltaQ.RTB.Utility;

This is not the same as if it hadn't touched it at all. So, I still have to be on the look-out for it and be careful not to commit changes with random noise as a result of this function.

from vscode-csharp.

logiclrd avatar logiclrd commented on August 20, 2024

If we're talking about ideals, it would actually be pretty cool if unimported types were listed in IntelliSense, and selecting one and pressing Tab inserted the text of the type name but not the using directive, but popped open/switched to a submenu which can then either be ignored, or Tab can select an "automatically add the corresponding using directive" menu item. That way, if you're doing it on purpose, you can still get the using directive, but if it's because you mistyped something, it doesn't happen by default.

from vscode-csharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.